mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Nav: Made hovering non-MenuItem Selectable not re-assign the source item for keyboard navigation.
This commit is contained in:
parent
4cfaf7d89c
commit
27079e68c2
@ -35,9 +35,13 @@ HOW TO UPDATE?
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Scrolling, Nav: Fixed programmatic scroll leading to a slightly incorrect scroll offset when
|
||||
- Nav, Scrolling: Fixed programmatic scroll leading to a slightly incorrect scroll offset when
|
||||
the window has decorations or a menu-bar (broken in 1.71). This was mostly noticeable when
|
||||
a keyboard/gamepad movement led to scrolling the view, or using e.g. SetScrollHereY() function.
|
||||
- Nav: Made hovering non-MenuItem Selectable not re-assign the source item for keyboard navigation.
|
||||
- Nav: Fixed an issue with NavFlattened window flag (beta) where widgets not entirely fitting
|
||||
in child window (often selectables because of their protruding sides) would be not considered
|
||||
as entry points to to navigate toward the child window. (#787)
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
@ -362,7 +362,8 @@ enum ImGuiSelectableFlagsPrivate_
|
||||
ImGuiSelectableFlags_PressedOnRelease = 1 << 22,
|
||||
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 23, // FIXME: We may be able to remove this (added in 6251d379 for menus)
|
||||
ImGuiSelectableFlags_AllowItemOverlap = 1 << 24,
|
||||
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 25 // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
||||
ImGuiSelectableFlags_DrawHoveredWhenHeld= 1 << 25, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow.
|
||||
ImGuiSelectableFlags_SetNavIdOnHover = 1 << 26
|
||||
};
|
||||
|
||||
// Extend ImGuiTreeNodeFlags_
|
||||
|
@ -5472,13 +5472,16 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
||||
const bool was_selected = selected;
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags);
|
||||
// Hovering selectable with mouse updates NavId accordingly so navigation can be resumed with gamepad/keyboard (this doesn't happen on most widgets)
|
||||
if (pressed || hovered)
|
||||
|
||||
// Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard
|
||||
if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover)))
|
||||
{
|
||||
if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent)
|
||||
{
|
||||
g.NavDisableHighlight = true;
|
||||
SetNavID(id, window->DC.NavLayerCurrent);
|
||||
}
|
||||
}
|
||||
if (pressed)
|
||||
MarkItemEdited(id);
|
||||
|
||||
@ -6178,7 +6181,9 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, boo
|
||||
ImVec2 pos = window->DC.CursorPos;
|
||||
ImVec2 label_size = CalcTextSize(label, NULL, true);
|
||||
|
||||
ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
|
||||
// We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73),
|
||||
// but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only.
|
||||
ImGuiSelectableFlags flags = ImGuiSelectableFlags_PressedOnRelease | ImGuiSelectableFlags_SetNavIdOnHover | (enabled ? 0 : ImGuiSelectableFlags_Disabled);
|
||||
bool pressed;
|
||||
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user