imgui-node-editor icon indicating copy to clipboard operation
imgui-node-editor copied to clipboard

Tooltips show up in wrong position

Open tksuoran opened this issue 8 months ago • 1 comments

Tooltips in node editor show up in wrong position.

Repro:

diff --git a/examples/basic-interaction-example/basic-interaction-example.cpp b/examples/basic-interaction-example/basic-interaction-example.cpp
index 4253533..7cc8991 100644
--- a/examples/basic-interaction-example/basic-interaction-example.cpp
+++ b/examples/basic-interaction-example/basic-interaction-example.cpp
@@ -77,6 +77,7 @@ struct Example:
             ed::SetNodePosition(nodeA_Id, ImVec2(10, 10));
         ed::BeginNode(nodeA_Id);
             ImGui::Text("Node A");
+            if (ImGui::IsItemHovered()) ImGui::SetTooltip("Node A Tooltip");
             ed::BeginPin(nodeA_InputPinId, ed::PinKind::Input);
                 ImGui::Text("-> In");
             ed::EndPin();

When I hover over the Node A, the tooltip shows up near top left window corner, instead on top of the node.

I guess this has to do with Canvas vs. Screen coordinate systems. What would I need to do to make tooltips work better?

Edit: I am in docking branch I have these:

#define IMGUI_VERSION       "1.91.9"
#define IMGUI_VERSION_NUM   19190
#define IMGUI_HAS_TABLE
#define IMGUI_HAS_VIEWPORT          // Viewport WIP branch
#define IMGUI_HAS_DOCK              // Docking WIP branch

tksuoran avatar Mar 20 '25 13:03 tksuoran

Workaround is to surround ImGui::SetTooltip() with Suspend() and Resume(). While this works for simple cases like SetTooltip(), I have not yet figured how to make more complex cases like ImGui::BeginCombo() to work.

tksuoran avatar Apr 07 '25 11:04 tksuoran

These two lines make BeginCombo to be rendered in the wrong position. Within the editor, these coords can be negative, and it clamps it. So, if you remove these two lines, it should work. Maybe there's a better way to handle it within if (policy == ImGuiPopupPositionPolicy_ComboBox) check in this function🤷‍♀️

Image

IceLuna avatar Nov 01 '25 13:11 IceLuna