mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 07:36:35 +00:00
Nav, ButtonBehavior: reworked old code which ended up 1) calling SetActiveId repeately and 2) misleadingly set g.NavActivateId (amend af38749e
)
This commit is contained in:
parent
ade4c15eea
commit
0a154b30ad
@ -604,13 +604,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
bool nav_activated_by_code = (g.NavActivateId == id);
|
||||
bool nav_activated_by_inputs = IsNavInputTest(ImGuiNavInput_Activate, (flags & ImGuiButtonFlags_Repeat) ? ImGuiInputReadMode_Repeat : ImGuiInputReadMode_Pressed);
|
||||
if (nav_activated_by_code || nav_activated_by_inputs)
|
||||
pressed = true;
|
||||
if (nav_activated_by_code || nav_activated_by_inputs || g.ActiveId == id)
|
||||
{
|
||||
// Set active id so it can be queried by user via IsItemActive(), equivalent of holding the mouse button.
|
||||
g.NavActivateId = id; // This is so SetActiveId assign a Nav source
|
||||
pressed = true;
|
||||
SetActiveID(id, window);
|
||||
if ((nav_activated_by_code || nav_activated_by_inputs) && !(flags & ImGuiButtonFlags_NoNavFocus))
|
||||
g.ActiveIdSource = ImGuiInputSource_Nav;
|
||||
if (!(flags & ImGuiButtonFlags_NoNavFocus))
|
||||
SetFocusID(id, window);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user