Closed hoffstadt closed 3 years ago
I also found this issue when using node editors in more than one window. The position of all nodes in their node editor are reset and nodes can't be moved.
Have you tried creating a separate ImNodesEditorContext
instance for the tabs? This is unfortunately something which isn't documented particularly well, but editing node graphs in separate canvases requires the creation of a separate editor context instance. See examples/multi_editor.cpp
for a an example on rendering two node graphs in separate ImGui windows. I think tabs should be supported as well.
Awesome, this fixed it. Here is the solution for those that come across this:
static auto context1 = imnodes::EditorContextCreate();
static auto context2 = imnodes::EditorContextCreate();
ImGui::Begin("Testing");
if (ImGui::BeginTabBar("Tab bar"))
{
if (ImGui::BeginTabItem("Tab 1"))
{
imnodes::EditorContextSet(context1);
imnodes::BeginNodeEditor();
imnodes::BeginNode(53);
ImGui::Dummy(ImVec2(80.0f, 45.0f));
imnodes::EndNode();
imnodes::EndNodeEditor();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Tab 2"))
{
imnodes::EditorContextSet(context2);
imnodes::BeginNodeEditor();
imnodes::BeginNode(54);
ImGui::Dummy(ImVec2(80.0f, 45.0f));
imnodes::EndNode();
imnodes::EndNodeEditor();
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::End();
System Information
Issue
Node positions are resetting after switching tabs that contain node editors. With multiple nodes, they all "pile up". See here.
Minimal Example
Position Before Switching Tabs (moved manually)
Position after switching between tabs
Notes