Nav: Fixed a few widgets from not setting reference keyboard/gamepad navigation ID when activated with mouse.

This commit is contained in:
ocornut 2021-09-13 15:17:54 +02:00
parent 17a7084b57
commit 82754561e2
4 changed files with 11 additions and 2 deletions

View File

@ -51,6 +51,11 @@ Other Changes:
to common idioms (e.g. passing .data(), .data() + .size() from a null string). (#3615) to common idioms (e.g. passing .data(), .data() + .size() from a null string). (#3615)
- Nav: Fixed toggling menu layer with Alt or exiting menu layer with Esc not moving mouse when - Nav: Fixed toggling menu layer with Alt or exiting menu layer with Esc not moving mouse when
the NavEnableSetMousePos config flag is set. the NavEnableSetMousePos config flag is set.
- Nav: Fixed a few widgets from not setting reference keyboard/gamepad navigation ID when
activated with mouse. More specifically: BeginTabItem(), the scrolling arrows of BeginTabBar(),
the arrow section of TreeNode(), the +/- buttons of InputInt()/InputFloat(), Selectable() with
ImGuiSelectableFlags_SelectOnRelease. More generally: any direct use of ButtonBehavior() with
the PressedOnClick/PressedOnDoubleClick/PressedOnRelease button policy.
- Menus: Adjust closing logic to accomodate for varying font size and dpi. - Menus: Adjust closing logic to accomodate for varying font size and dpi.
- Menus: Fixed crash when navigating left inside a child window inside a sub-menu. (#4510). - Menus: Fixed crash when navigating left inside a child window inside a sub-menu. (#4510).
- Drag and Drop: Fixed using BeginDragDropSource() inside a BeginChild() that returned false. (#4515) - Drag and Drop: Fixed using BeginDragDropSource() inside a BeginChild() that returned false. (#4515)

View File

@ -64,7 +64,7 @@ Index of this file:
// Version // Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
#define IMGUI_VERSION "1.85 WIP" #define IMGUI_VERSION "1.85 WIP"
#define IMGUI_VERSION_NUM 18413 #define IMGUI_VERSION_NUM 18414
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE

View File

@ -1170,7 +1170,7 @@ void ImGui::TableUpdateBorders(ImGuiTable* table)
KeepAliveID(column_id); KeepAliveID(column_id);
bool hovered = false, held = false; bool hovered = false, held = false;
bool pressed = ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick); bool pressed = ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_NoNavFocus);
if (pressed && IsMouseDoubleClicked(0)) if (pressed && IsMouseDoubleClicked(0))
{ {
TableSetColumnWidthAutoSingle(table, column_n); TableSetColumnWidthAutoSingle(table, column_n);

View File

@ -571,6 +571,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
ClearActiveID(); ClearActiveID();
else else
SetActiveID(id, window); // Hold on ID SetActiveID(id, window); // Hold on ID
if (!(flags & ImGuiButtonFlags_NoNavFocus))
SetFocusID(id, window);
g.ActiveIdMouseButton = mouse_button_clicked; g.ActiveIdMouseButton = mouse_button_clicked;
FocusWindow(window); FocusWindow(window);
} }
@ -581,6 +583,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
const bool has_repeated_at_least_once = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button_released] >= g.IO.KeyRepeatDelay; const bool has_repeated_at_least_once = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button_released] >= g.IO.KeyRepeatDelay;
if (!has_repeated_at_least_once) if (!has_repeated_at_least_once)
pressed = true; pressed = true;
if (!(flags & ImGuiButtonFlags_NoNavFocus))
SetFocusID(id, window);
ClearActiveID(); ClearActiveID();
} }