Skip to content

Commit 7ac23db

Browse files
committed
[Bundle]: add DisableUserInputThisFrame
1 parent 8432ebb commit 7ac23db

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
@@ -1034,6 +1034,7 @@ ed::EditorContext::EditorContext(const ax::NodeEditor::Config* config)
10341034
, m_IsFocused(false)
10351035
, m_IsHovered(false)
10361036
, m_IsHoveredWithoutOverlapp(false)
1037+
, m_EnableUserInput(true)
10371038
, m_ShortcutsEnabled(true)
10381039
, m_Style()
10391040
, m_Nodes()
@@ -1085,6 +1086,7 @@ ed::EditorContext::~EditorContext()
10851086

10861087
void ed::EditorContext::Begin(const char* id, const ImVec2& size)
10871088
{
1089+
m_EnableUserInput = true;
10881090
m_EditorActiveId = ImGui::GetID(id);
10891091
ImGui::PushID(id);
10901092

@@ -1294,10 +1296,13 @@ void ed::EditorContext::End()
12941296
if (m_CurrentAction && !m_CurrentAction->Process(control))
12951297
m_CurrentAction = nullptr;
12961298

1297-
if (m_NavigateAction.m_IsActive)
1298-
m_NavigateAction.Process(control);
1299-
else
1300-
m_NavigateAction.Accept(control);
1299+
if (m_EnableUserInput)
1300+
{
1301+
if (m_NavigateAction.m_IsActive)
1302+
m_NavigateAction.Process(control);
1303+
else
1304+
m_NavigateAction.Accept(control);
1305+
}
13011306

13021307
if (nullptr == m_CurrentAction)
13031308
{
@@ -1966,7 +1971,12 @@ bool ed::EditorContext::IsHoveredWithoutOverlapp() const
19661971

19671972
bool ed::EditorContext::CanAcceptUserInput() const
19681973
{
1969-
return m_IsFocused && m_IsHovered;
1974+
return m_IsFocused && m_IsHovered && m_EnableUserInput;
1975+
}
1976+
1977+
void ed::EditorContext::DisableUserInputThisFrame()
1978+
{
1979+
m_EnableUserInput = false;
19701980
}
19711981

19721982
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)