Nav: pressing any keyboard key while holding Alt disable toggling nav layer on Alt release. (#4439, extend #370, #369)

This commit is contained in:
ocornut 2024-09-05 20:16:37 +02:00
parent 193c1e2366
commit d16cb171c6
2 changed files with 7 additions and 1 deletions

View File

@ -43,6 +43,8 @@ Breaking changes:
Other changes:
- Nav: pressing any keyboard key while holding Alt disable toggling nav layer on Alt release. (#4439)
-----------------------------------------------------------------------
VERSION 1.91.1 (Released 2024-09-04)
-----------------------------------------------------------------------

View File

@ -13182,9 +13182,11 @@ static void ImGui::NavUpdateWindowing()
// Keyboard: Press and Release ALT to toggle menu layer
const ImGuiKey windowing_toggle_keys[] = { ImGuiKey_LeftAlt, ImGuiKey_RightAlt };
bool windowing_toggle_layer_start = false;
for (ImGuiKey windowing_toggle_key : windowing_toggle_keys)
if (nav_keyboard_active && IsKeyPressed(windowing_toggle_key, 0, ImGuiKeyOwner_NoOwner))
{
windowing_toggle_layer_start = true;
g.NavWindowingToggleLayer = true;
g.NavWindowingToggleKey = windowing_toggle_key;
g.NavInputSource = ImGuiInputSource_Keyboard;
@ -13198,7 +13200,9 @@ static void ImGui::NavUpdateWindowing()
// We cancel toggling nav layer if an owner has claimed the key.
if (io.InputQueueCharacters.Size > 0 || io.KeyCtrl || io.KeyShift || io.KeySuper)
g.NavWindowingToggleLayer = false;
if (TestKeyOwner(g.NavWindowingToggleKey, ImGuiKeyOwner_NoOwner) == false || TestKeyOwner(ImGuiMod_Alt, ImGuiKeyOwner_NoOwner) == false)
else if (windowing_toggle_layer_start == false && g.LastKeyboardKeyPressTime == g.Time)
g.NavWindowingToggleLayer = false;
else if (TestKeyOwner(g.NavWindowingToggleKey, ImGuiKeyOwner_NoOwner) == false || TestKeyOwner(ImGuiMod_Alt, ImGuiKeyOwner_NoOwner) == false)
g.NavWindowingToggleLayer = false;
// Apply layer toggle on Alt release