Skip to content

Commit 211b47e

Browse files
ocornutactondev
authored andcommitted
Nav: enable move/resize window with keyboard in Ctrl+Tabbing windowing menu even without _NavEnableKeyboard. (ocornut#4023, ocornut#787).
1 parent 4d5f91c commit 211b47e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Diff for: docs/CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Other Changes:
4646
- Fixed IsWindowFocused()/IsWindowHovered() issues with childs inside popups. (#4676)
4747
- Nav: Ctrl+tabbing to cycle through windows is now enabled regardless of using the _NavEnableKeyboard
4848
configuration flag. This is part of an effort to generalize the use of keyboard inputs. (#4023, #787).
49+
Note that while this is active you can also moving windows (with arrow) and resize (shift+arrows).
4950
- Nav: tabbing now cycles through clipped items and scroll accordingly. (#4449)
5051
- Nav: pressing PageUp/PageDown/Home/End when in Menu layer automatically moves back to Main layer.
5152
- Nav: fixed resizing window from borders setting navigation to Menu layer.

Diff for: imgui.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -5523,7 +5523,7 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s
55235523
{
55245524
ImVec2 nav_resize_delta;
55255525
if (g.NavInputSource == ImGuiInputSource_Keyboard && g.IO.KeyShift)
5526-
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
5526+
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_RawKeyboard, ImGuiInputReadMode_Down);
55275527
if (g.NavInputSource == ImGuiInputSource_Gamepad)
55285528
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down);
55295529
if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f)
@@ -9335,6 +9335,8 @@ float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
93359335
ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor)
93369336
{
93379337
ImVec2 delta(0.0f, 0.0f);
9338+
if (dir_sources & ImGuiNavDirSourceFlags_RawKeyboard)
9339+
delta += ImVec2((float)IsKeyDown(GetKeyIndex(ImGuiKey_RightArrow)) - (float)IsKeyDown(GetKeyIndex(ImGuiKey_LeftArrow)), (float)IsKeyDown(GetKeyIndex(ImGuiKey_DownArrow)) - (float)IsKeyDown(GetKeyIndex(ImGuiKey_UpArrow)));
93389340
if (dir_sources & ImGuiNavDirSourceFlags_Keyboard)
93399341
delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode));
93409342
if (dir_sources & ImGuiNavDirSourceFlags_PadDPad)
@@ -10101,7 +10103,7 @@ static void ImGui::NavUpdateWindowing()
1010110103
{
1010210104
ImVec2 move_delta;
1010310105
if (g.NavInputSource == ImGuiInputSource_Keyboard && !io.KeyShift)
10104-
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
10106+
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_RawKeyboard, ImGuiInputReadMode_Down);
1010510107
if (g.NavInputSource == ImGuiInputSource_Gamepad)
1010610108
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down);
1010710109
if (move_delta.x != 0.0f || move_delta.y != 0.0f)

Diff for: imgui_internal.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1230,9 +1230,10 @@ enum ImGuiNavHighlightFlags_
12301230
enum ImGuiNavDirSourceFlags_
12311231
{
12321232
ImGuiNavDirSourceFlags_None = 0,
1233-
ImGuiNavDirSourceFlags_Keyboard = 1 << 0,
1234-
ImGuiNavDirSourceFlags_PadDPad = 1 << 1,
1235-
ImGuiNavDirSourceFlags_PadLStick = 1 << 2
1233+
ImGuiNavDirSourceFlags_RawKeyboard = 1 << 0, // Raw keyboard (not pulled from nav), faciliate use of some functions before we can unify nav and keys
1234+
ImGuiNavDirSourceFlags_Keyboard = 1 << 1,
1235+
ImGuiNavDirSourceFlags_PadDPad = 1 << 2,
1236+
ImGuiNavDirSourceFlags_PadLStick = 1 << 3
12361237
};
12371238

12381239
enum ImGuiNavMoveFlags_

0 commit comments

Comments
 (0)