-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
IsItemHovered(), IsWindowHovered() improvements #1382
Comments
I now get these errors in the demo file: src/imgui_demo.cpp:1776:40: error: use of undeclared identifier 'ImGuiHoveredFlags_AllowWhenBlockedByPopup'
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
^
src/imgui_demo.cpp:1777:40: error: use of undeclared identifier 'ImGuiHoveredFlags_AllowWhenBlockedByActiveItem'
ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem));
^
src/imgui_demo.cpp:1788:38: error: use of undeclared identifier 'ImGuiHoveredFlags_AllowWhenBlockedByPopup'
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup),
^
src/imgui_demo.cpp:1789:38: error: use of undeclared identifier 'ImGuiHoveredFlags_AllowWhenBlockedByActiveItem'
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem),
^
src/imgui_demo.cpp:1790:38: error: use of undeclared identifier 'ImGuiHoveredFlags_AllowWhenOverlapped'
ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped),
^
src/imgui_demo.cpp:1791:38: error: use of undeclared identifier 'ImGuiHoveredFlags_RectOnly'
ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly)); Edit: I managed to fix this by updating the other files however IMGUI's windows don't scale in ratio to the size of my window. How do I fix this? |
I mean the widgets |
Those enums are in imgui.h afaik so you must have messed up with something locally. Are you using stock imgui or did you modify or merge something manually?
…Sent from my fax machine
|
What happened was that I downloaded the demo file but forgot to update the other files. |
Everyone who is using The change described here introduced a bug that affects the console demo (see #1404, unable to open the right-click context menu while hovering the child window, because another widget is active). The fix for that one thing is easy but it led me to question exactly how So seeing your usage patterns would be useful. |
… ChildWindows and RootWindow flags. Allowing more combination and a better symetry with IsWindowFocused() flags. (#1382)
Marked IsRootWindowFocused() as obsolete in favor of using IsWindowFocused(ImGuiFocusedFlags_RootWindow). Marked IsRootWindowOrAnyChildFocused() as obsolete in favor of using IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows).
I have made the same transition for IsWindowFocused, which now has flags and can handle more cases:
So essentially:
In addition it's now possible to do:
|
Closing this as solved. |
…eted IsAnyWindowHovered()/IsAnyWindowFocused() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow)/IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Added to demo. (#1382)
…. static only tends to trigger warnings. (#1382)
ImGuiHoveredFlags_Default isn't a valid identifier. It seems it perhaps was at some point, but the flag that's in the api is ImGuiHoveredFlags_None. I see the former mentioned in ocornut#1382, and its description is the same as what is now given to None.
Since I didn't find a way to change a text color on hover with my hand-made icon font, I did it myself
|
(This is a news/info post. Will close in a few days)
I have pushed a bunch of changes related to the IsItemHovered() and IsWindowHovered() functions, in the form of new flags.
This is interesting to know:
Previously it was frequent to use
IsItemRectHovered
/IsItemHoveredRect
(same function, was renamed on August 22) to do a basic rectangle-only test.The existing normal functions now have flags to allow this and more, with better defined options:
The flags are:
This is particularly useful for contextual menu triggered from an item. The high-level
BeginPopupContextItem()
helper now uses theImGuiHoveredFlags_AllowWhenBlockedByPopup
flag meaning that you can right-click again on a different spot to reopen a context menu. (Popup menu right click behavior #439). Note that I also have committed another change that allows closing popups by right-clicking anywhere, making popups generally more usable.Those new options will make it easier/clearer to have finer controls on drag and drop related behaviour.
If you use e.g. tooltip you can also have finer controls as to how when they should appear.
In the demo window you can visualize the output of those functions will different flags:
Above: normal hovering.
Above: Here the button is hidden by another window, but
IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped)
/RectOnly
call returns true as expected:Above: Here there is an open popup (the color picker) which prevents from clicking the button "ITEM" (so it doesn't appear as hovered). The
IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)
andIsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)
calls both returns true.Above: Here I have clicked on the DRAG ME button and click-dragged the mouse over the ITEM button. The
IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)
returns true.Hope it is clear, and useful!
I haven't worked out in details how those features may relate to parent-child window relationship, and I imagine we could introduce new flags there.
BREAKING CHANGES
IsItemHoveredRect/IsItemRectHovered
has been obsoleted, it is equivalent to calling:IsItemHovered(ImGuiHoveredFlags_RectOnly)
aka all the flags enabled. I have kept an inline function doing that.On August 22 I renamed
IsItemHoveredRect
toIsItemRectHovered
for consistency with other functions. Instead of keeping 2 legacy names, I have now completely removed the name introduced on August 22, since few people will have renamed it their code, and if they did they are likely to find their way through the new changes. So only the oldest legacy name persist and it will be obsoleted in a few months/years.Similarly,
IsWindowRectHovered()
has been obsoleted, the exact behavior that it had is equivalent to callingIsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)
.Similarly, on August 22 I renamed
IsMouseHoveringWindow
toIsWindowRectHovered
and I have removed the most recently introduced name. So the oldest legacy nameIsMouseHoveringWindow
will persist for a few more months/years.IsWindowHovered()
default behavior has been changed to return false if an item of another window is active. It makes the function more consistent and symmetrical withIsItemHovered()
and I believe it is a better default and won't affect many people. You can callIsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)
to get the old behavior.This will probably affect you if you were doing drag and drop across windows and using
IsWindowHovered
.The text was updated successfully, but these errors were encountered: