mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-27 04:00:22 +00:00
Menus: Fixed using IsItemHovered()/IsItemClicked() on BeginMenu(). (#5775)
This commit is contained in:
parent
3920b1c764
commit
81176737f8
@ -144,6 +144,7 @@ Other Changes:
|
|||||||
towards a sub-menu. (#2517, #5614). [@rokups]
|
towards a sub-menu. (#2517, #5614). [@rokups]
|
||||||
- Menus: Fixed gaps in closing logic which would make child-menu erroneously close when crossing
|
- Menus: Fixed gaps in closing logic which would make child-menu erroneously close when crossing
|
||||||
the gap between a menu item inside a window and a child-menu in a secondary viewport. (#5614)
|
the gap between a menu item inside a window and a child-menu in a secondary viewport. (#5614)
|
||||||
|
- Menus: Fixed using IsItemHovered()/IsItemClicked() on BeginMenu(). (#5775)
|
||||||
- Menus, Nav: Fixed keyboard/gamepad navigation occasionally erroneously landing on menu-item
|
- Menus, Nav: Fixed keyboard/gamepad navigation occasionally erroneously landing on menu-item
|
||||||
in parent window when the parent is not a popup. (#5730)
|
in parent window when the parent is not a popup. (#5730)
|
||||||
- Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (#5730)
|
- Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (#5730)
|
||||||
|
@ -3640,7 +3640,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||||||
|
|
||||||
// Test if interactions on this window are blocked by an active popup or modal.
|
// Test if interactions on this window are blocked by an active popup or modal.
|
||||||
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
||||||
if (!IsWindowContentHoverable(window, flags))
|
if (!IsWindowContentHoverable(window, flags) && !(g.LastItemData.InFlags & ImGuiItemFlags_NoWindowHoverableCheck))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Test if the item is disabled
|
// Test if the item is disabled
|
||||||
|
2
imgui.h
2
imgui.h
@ -23,7 +23,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
|
||||||
#define IMGUI_VERSION "1.89 WIP"
|
#define IMGUI_VERSION "1.89 WIP"
|
||||||
#define IMGUI_VERSION_NUM 18831
|
#define IMGUI_VERSION_NUM 18832
|
||||||
#define IMGUI_HAS_TABLE
|
#define IMGUI_HAS_TABLE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7125,11 +7125,19 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
|
|
||||||
if (menu_is_open)
|
if (menu_is_open)
|
||||||
{
|
{
|
||||||
// FIXME: This technically breaks functions relying on LastItemData, somehow nobody complained yet. Should backup/restore LastItemData.
|
ImGuiLastItemData last_item_in_parent = g.LastItemData;
|
||||||
SetNextWindowPos(popup_pos, ImGuiCond_Always); // Note: misleading: the value will serve as reference for FindBestWindowPosForPopup(), not actual pos.
|
SetNextWindowPos(popup_pos, ImGuiCond_Always); // Note: misleading: the value will serve as reference for FindBestWindowPosForPopup(), not actual pos.
|
||||||
PushStyleVar(ImGuiStyleVar_ChildRounding, style.PopupRounding); // First level will use _PopupRounding, subsequent will use _ChildRounding
|
PushStyleVar(ImGuiStyleVar_ChildRounding, style.PopupRounding); // First level will use _PopupRounding, subsequent will use _ChildRounding
|
||||||
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
|
if (menu_is_open)
|
||||||
|
{
|
||||||
|
// Restore LastItemData so IsItemXXXX functions can work after BeginMenu()/EndMenu()
|
||||||
|
// (This fixes using IsItemClicked() and IsItemHovered(), but IsItemHovered() also relies on its support for ImGuiItemFlags_NoWindowHoverableCheck)
|
||||||
|
g.LastItemData = last_item_in_parent;
|
||||||
|
if (g.HoveredWindow == window)
|
||||||
|
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user