Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup with child does not show tooltip when hovered #197

Closed
unpacklo opened this issue Apr 16, 2015 · 6 comments
Closed

Popup with child does not show tooltip when hovered #197

unpacklo opened this issue Apr 16, 2015 · 6 comments

Comments

@unpacklo
Copy link

Hey Omar,

I've been checking out some of the popup functionality you implemented in your last release and I noticed an issue in my application while using it with a child region inside the popup. This code illustrates the issue:

        ImGui::Begin("Popup tooltip bug");

        static bool popup = false;
        popup ^= ImGui::Button("Popup");

        static bool usePopupChild = false;
        ImGui::Checkbox("Use popup child", &usePopupChild);

        if (popup)
        {
            ImGui::BeginPopup(&popup);

            if (usePopupChild)
                ImGui::BeginChild("popup child", ImVec2(100.0f, 100.0f));

            if (ImGui::Selectable("abcd"))
                popup = false;
            if (ImGui::IsItemHovered())
                ImGui::SetTooltip("abcd");

            if (ImGui::Selectable("efgh"))
                popup = false;
            if (ImGui::IsItemHovered())
                ImGui::SetTooltip("efgh");

            if (ImGui::Selectable("hijk"))
                popup = false;
            if (ImGui::IsItemHovered())
                ImGui::SetTooltip("hijk");

            if (usePopupChild)
                ImGui::EndChild();

            ImGui::EndPopup();
        }

        ImGui::End();

When you open the popup with a child region, the tooltips don't show up when hovering over the popup items until you click inside the region, then the tooltips will show. Without the child region, the tooltips show up as expected.

The way I'm using the popups in my game, I use it to bring up a file selection interface. Oftentimes, I'll have thousands of entries that need to be viewed, so I use the child region to keep the popup small and allow for scrolling:

untitled

With the absence of horizontal scrolling, we use tooltips a lot to show file paths in the case that they're too large for a window/child region, but not a huge issue by any means.

Side note: Would it be possible to allow for the popup to have a border, the same way a child region can have a border? The idea is to let the popup's area be more obvious; our color scheme makes the popup a little hard to spot sometimes!

Thanks again, keep up the awesome work!

-Dale Kim

@ocornut
Copy link
Owner

ocornut commented Apr 16, 2015

Bug: Looking into it..

Borders:
Essentially BeginPopup() should have the same API as BeginChild() ? Without the identifier. There's no identifier because there can only be one popup on screen. However I haven't tested edge cases of trying to use different popups from frame to frame and there might be leaks of size/positional data involved. I haven't thought deeply if the lack of identifier for popups can eventually be a problem or not.

I was wondering if 'bool border' could be removed and be part of flags, 'ImGuiWindowFlags_Border', that depends how common border are. The current child parameter is odd side-stepping from the regular PushStyle/PopStyle system (yet somehow useful? or not? wouldn't it make more sense to bake it in the style?)

Horizontal scrolling: Yeah..probably not hard to add, need to see how it impacts (or not) auto-sizing features.

@ocornut
Copy link
Owner

ocornut commented Apr 16, 2015

OK so the bug isn't actually related to tooltip but a bug with IsItemHovered() and child window inside a popup. Because popups disable hovering on other windows, but they shouldn't disable it for their child window (that's the bug). That also repros it:

        {
            ImGui::Begin("Popup tooltip bug");

            static bool popup = false;
            popup ^= ImGui::Button("Popup");

            static bool usePopupChild = false;
            ImGui::Checkbox("Use popup child", &usePopupChild);

            if (popup)
            {
                ImGui::BeginPopup(&popup);

                if (usePopupChild)
                    ImGui::BeginChild("popup child", ImVec2(100.0f, 100.0f));

                ImGui::Text("Hover me");
                if (ImGui::IsItemHovered())
                    ImGui::Text("Hovered");

                if (usePopupChild)
                    ImGui::EndChild();

                ImGui::EndPopup();
            }

            ImGui::End();
        }

ocornut added a commit that referenced this issue Apr 16, 2015
@ocornut
Copy link
Owner

ocornut commented Apr 16, 2015

Main bug is fixed. I may just close that and add border options as a separate bug #

@unpacklo
Copy link
Author

Tried it out and it works great now! Definitely can close this if you want.

@ocornut
Copy link
Owner

ocornut commented May 3, 2015

Border:

  • I made popup have borders by default. It seemed unnecessary to add an option for now (if I do so I'd like to use the same parameters as BeginChild and would need to test the sizing options, but they seem unecessary for now). Let me know if you think there is a use for disabling the border.
  • Their alpha is 1.0 (like combo box, not part of style yet).
  • I also made border color use 65% alpha instead. Border color used for separator, etc. I think it looks better this way.

I don't want to worry too much about styling issue for now but the border is a readability issue. With it and the opaque window it is better.

@unpacklo
Copy link
Author

Finally got around to checking it out, the border makes the popup much nicer!

I haven't run into any case yet where I would want to disable the border, but maybe someone else has?

@ocornut ocornut added the popups label Aug 16, 2017
idbrii added a commit to idbrii/cpp-imgui that referenced this issue Mar 24, 2025
Includes my merged PRs and everything in my dev branch. Haven't tested
with it yet.

Changelog:
Test case for clip rect
HACK: more recent Windows SDK and VS2017; disable graph
Set size to amount of space required
Merge pull request ocornut#349 from maksw2/master
Merge pull request ocornut#347 from mgerhardy/341
Merge pull request ocornut#348 from mgerhardy/fixed-warning
Merge pull request ocornut#346 from mgerhardy/280
Merge pull request ocornut#345 from mgerhardy/322
Merge pull request ocornut#344 from rherilier/fix-gcc-warnings
Merge pull request ocornut#336 from rherilier/add-isusingviewmanipulate
Merge pull request ocornut#335 from RedSkittleFox/alternative_window
Merge pull request ocornut#334 from ocornut/fix-beginchildframe
dear imgui update and small fixes
Merge pull request ocornut#316 from Batres3/2DSupport
Merge pull request ocornut#326 from Sayama3/use-push-pop-id
Merge pull request ocornut#328 from georgeto/master
Merge pull request ocornut#330 from maritim/master
Merge pull request ocornut#331 from GiovanyH/patch-1
Merge pull request ocornut#318 from dougbinks/imgui_math_operators
Merge pull request ocornut#312 from kimidaisuki22/master
div 0 fixed
Merge pull request ocornut#301 from ZingBallyhoo/using-any
Merge pull request ocornut#300 from Clog41200/Configurable-limits
Merge pull request ocornut#298 from xDUDSSx/fix/rotation_circles
Merge pull request ocornut#297 from xDUDSSx/fix/vertical-aspect-scaling
Merge pull request ocornut#289 from ComputationalBiomechanicsLab/fix_isusing-ignores-setid
Merge pull request ocornut#291 from ocornut/fix_math_operators_include
Merge pull request ocornut#282 from MohitSethi99/master
Merge pull request ocornut#276 from pthom/virtual_destructors
Merge pull request ocornut#271 from idbrii/clip-parent
Merge pull request ocornut#270 from idbrii/btn-behaviour
Merge pull request ocornut#265 from mgerhardy/pr/fix-minor-formatting
Merge pull request ocornut#264 from mgerhardy/pr/div0
Merge pull request ocornut#269 from peter1745/hatched-line-thickness-enhancement
Merge pull request ocornut#259 from miyanyan/master
Merge branch 'master' of https://github.com/CedricGuillemet/ImGuizmo
update dear imgui
Merge pull request ocornut#256 from Aidiakapi/patch-1
Merge pull request ocornut#252 from aaronkirkham/master
Merge pull request ocornut#249 from rokups/rk/mouse-capture
Merge pull request ocornut#246 from mgerhardy/pr/viewmanipulate
removed commented code
fix click view cube
Merge pull request ocornut#231 from mgerhardy/master
Merge pull request ocornut#230 from mgerhardy/master
Merge pull request ocornut#228 from longod/master
Merge pull request ocornut#227 from madeso/master
AddBezierCubic
Merge pull request ocornut#226 from sherief/master
revert culling test commit
Merge pull request ocornut#203 from rokups/rk/misc-fixes
Merge pull request ocornut#212 from zhaijialong/fix-behind-camera-cull
Merge pull request ocornut#209 from VictorFouquet/fix_normalize
scale is always local
Merge pull request ocornut#202 from pezy/master
imguizmo namespace
Merge pull request ocornut#194 from JonathanHiggs/vcpkg-example
1.84 WIP
Merge pull request ocornut#197 from idbrii/seq-btn-color
Merge pull request ocornut#196 from idbrii/seq-big-handles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants