@@ -1055,6 +1055,7 @@ ImRect ed::Link::GetBounds() const
1055
1055
// ------------------------------------------------------------------------------
1056
1056
ed::EditorContext::EditorContext (const ax::NodeEditor::Config* config)
1057
1057
: m_Config(config)
1058
+ , m_EditorActiveId(0 )
1058
1059
, m_IsFirstFrame(true )
1059
1060
, m_IsFocused(false )
1060
1061
, m_IsHovered(false )
@@ -1145,6 +1146,7 @@ void ed::EditorContext::Begin(const char* id, const ImVec2& size)
1145
1146
ImDrawList_SwapSplitter (m_DrawList, m_Splitter);
1146
1147
m_ExternalChannel = m_DrawList->_Splitter ._Current ;
1147
1148
1149
+ m_EditorActiveId = ImGui::GetID (id);
1148
1150
ImGui::PushID (id);
1149
1151
1150
1152
auto availableContentSize = ImGui::GetContentRegionAvail ();
@@ -2305,6 +2307,7 @@ ed::Control ed::EditorContext::BuildControl(bool allowOffscreen)
2305
2307
ImGui::PushClipRect (editorRect.Min , editorRect.Max , false );
2306
2308
}
2307
2309
2310
+ ImGuiID activeId = 0 ;
2308
2311
Object* hotObject = nullptr ;
2309
2312
Object* activeObject = nullptr ;
2310
2313
Object* clickedObject = nullptr ;
@@ -2342,7 +2345,7 @@ ed::Control ed::EditorContext::BuildControl(bool allowOffscreen)
2342
2345
};
2343
2346
2344
2347
// Emits invisible button and returns true if it is clicked.
2345
- auto emitInteractiveAreaEx = [](ObjectId id, const ImRect& rect, ImGuiButtonFlags extraFlags) -> int
2348
+ auto emitInteractiveAreaEx = [&activeId ](ObjectId id, const ImRect& rect, ImGuiButtonFlags extraFlags) -> int
2346
2349
{
2347
2350
char idString[33 ] = { 0 }; // itoa can output 33 bytes maximum
2348
2351
snprintf (idString, 32 , " %p" , id.AsPointer ());
@@ -2356,6 +2359,9 @@ ed::Control ed::EditorContext::BuildControl(bool allowOffscreen)
2356
2359
// #debug
2357
2360
// ImGui::GetWindowDrawList()->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(0, 255, 0, 64));
2358
2361
2362
+ if (ImGui::IsItemActive ())
2363
+ activeId = ImGui::GetActiveID ();
2364
+
2359
2365
return buttonIndex;
2360
2366
};
2361
2367
@@ -2507,6 +2513,12 @@ ed::Control ed::EditorContext::BuildControl(bool allowOffscreen)
2507
2513
backgroundDoubleClickButtonIndex = -1 ;
2508
2514
}
2509
2515
2516
+ if (activeId)
2517
+ m_EditorActiveId = activeId;
2518
+
2519
+ if (ImGui::IsAnyItemActive () && ImGui::GetActiveID () != m_EditorActiveId)
2520
+ return Control ();
2521
+
2510
2522
m_IsHovered = ImGui::IsItemHovered (ImGuiHoveredFlags_RectOnly);
2511
2523
m_IsHoveredWithoutOverlapp = ImGui::IsItemHovered ();
2512
2524
if (!allowOffscreen && !m_IsHovered)
0 commit comments