Skip to content

Commit d6fc682

Browse files
committed
[Bundle]: add DisableUserInputThisFrame
1 parent 36802c2 commit d6fc682

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

imgui_node_editor.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ ed::EditorContext::EditorContext(const ax::NodeEditor::Config* config)
10741074
, m_IsFocused(false)
10751075
, m_IsHovered(false)
10761076
, m_IsHoveredWithoutOverlapp(false)
1077+
, m_EnableUserInput(true)
10771078
, m_ShortcutsEnabled(true)
10781079
, m_Style()
10791080
, m_Nodes()
@@ -1125,6 +1126,7 @@ ed::EditorContext::~EditorContext()
11251126

11261127
void ed::EditorContext::Begin(const char* id, const ImVec2& size)
11271128
{
1129+
m_EnableUserInput = true;
11281130
m_EditorActiveId = ImGui::GetID(id);
11291131
ImGui::PushID(id);
11301132

@@ -1334,10 +1336,13 @@ void ed::EditorContext::End()
13341336
if (m_CurrentAction && !m_CurrentAction->Process(control))
13351337
m_CurrentAction = nullptr;
13361338

1337-
if (m_NavigateAction.m_IsActive)
1338-
m_NavigateAction.Process(control);
1339-
else
1340-
m_NavigateAction.Accept(control);
1339+
if (m_EnableUserInput)
1340+
{
1341+
if (m_NavigateAction.m_IsActive)
1342+
m_NavigateAction.Process(control);
1343+
else
1344+
m_NavigateAction.Accept(control);
1345+
}
13411346

13421347
if (nullptr == m_CurrentAction)
13431348
{
@@ -2006,7 +2011,12 @@ bool ed::EditorContext::IsHoveredWithoutOverlapp() const
20062011

20072012
bool ed::EditorContext::CanAcceptUserInput() const
20082013
{
2009-
return m_IsFocused && m_IsHovered;
2014+
return m_IsFocused && m_IsHovered && m_EnableUserInput;
2015+
}
2016+
2017+
void ed::EditorContext::DisableUserInputThisFrame()
2018+
{
2019+
m_EnableUserInput = false;
20102020
}
20112021

20122022
int ed::EditorContext::CountLiveNodes() const

imgui_node_editor_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,9 @@ struct EditorContext
13711371
bool IsHoveredWithoutOverlapp() const;
13721372
bool CanAcceptUserInput() const;
13731373

1374+
// This is *specific* to ImGui Bundle
1375+
void DisableUserInputThisFrame();
1376+
13741377
void MakeDirty(SaveReasonFlags reason);
13751378
void MakeDirty(SaveReasonFlags reason, Node* node);
13761379

@@ -1490,6 +1493,7 @@ struct EditorContext
14901493
bool m_IsFocused;
14911494
bool m_IsHovered;
14921495
bool m_IsHoveredWithoutOverlapp;
1496+
bool m_EnableUserInput; // Specific to ImGui Bundle. When false, discard all user inputs
14931497

14941498
bool m_ShortcutsEnabled;
14951499

0 commit comments

Comments
 (0)