cimgui-go
cimgui-go copied to clipboard
How to constrain a Tooltip to a window?
I noticed some odd behavior when the tooltip goes over the edge of the window. On Debian 12 (I can collect more info about my system if needed, but it's basically vanilla Debian), the tooltip creates a new window named "No Title Yet". This new window takes focus away from the original window, and feels a bit bit laggy.
Demo: https://github.com/user-attachments/assets/51065f86-4d96-4625-bfa7-6b5dcc99a8ca Code: https://gist.github.com/Omustardo/e1bb32296d0b51b88bc12133e6bb8667
A slightly more minimal example:
vp := imgui.MainViewport()
imgui.SetNextWindowPosV(vp.Pos(), imgui.CondOnce, imgui.NewVec2(0, 0))
imgui.SetNextWindowSize(vp.Size())
imgui.BeginV("Window1", nil, 0)
{
imgui.Text("TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST")
if imgui.BeginItemTooltip() {
imgui.Text("TOOLTIP")
imgui.EndTooltip()
}
}
imgui.End()
To reproduce, mouseover the "TEST TEST" content all the way on the right of it, so that the tooltip goes outside of the native OS window.
Is there a reliable way constrain a tooltip to the window that its creation was triggered from?
I can do it by calculating the size of the tooltip and using SetNextWindowPos
. This is fine for text tooltips, but if I had more widgets in the tooltip it might be a pain. https://gist.github.com/Omustardo/bbf784a6865809d54fed493e42a0e964
I expect this is an issue in https://github.com/ocornut/imgui/ since it deals with just the C bindings. I reported it in this repo rather than that one because I haven't tested it in C.