From cb46908268b2bbfcfc60169507bf9adf155cb0b9 Mon Sep 17 00:00:00 2001 From: MrTheShy <49885496+MrTheShy@users.noreply.github.com> Date: Thu, 5 Mar 2026 23:44:48 +0100 Subject: [PATCH] Fix keyboard/arrow navigation not working when no UI element is focused On Windows64 with KBM, moving the mouse over empty space (outside any button) would clear the Iggy focus entirely. After that, pressing arrow keys did nothing because Flash had no starting element to navigate from. Two changes here: - Don't set focus to IGGY_FOCUS_NULL when the mouse hovers over empty space. The previous hover target stays focused, so switching back to arrows keeps working seamlessly. - When a navigation key is pressed and nothing is focused at all (e.g. mouse was already on empty space when the menu opened), grab the first focusable element instead of silently dropping the input. The keypress is consumed to avoid jumping two elements at once. This makes mixed mouse+keyboard navigation feel a lot more natural. You can point at a button, then continue with arrows, or just start pressing arrows right away without having to hover first. --- Minecraft.Client/Common/UI/UIController.cpp | 2 +- Minecraft.Client/Common/UI/UIScene.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Minecraft.Client/Common/UI/UIController.cpp b/Minecraft.Client/Common/UI/UIController.cpp index 5375b784d..ad35894a5 100644 --- a/Minecraft.Client/Common/UI/UIController.cpp +++ b/Minecraft.Client/Common/UI/UIController.cpp @@ -846,7 +846,7 @@ void UIController::tickInput() } } - if (hitObject != currentFocus) + if (hitObject != IGGY_FOCUS_NULL && hitObject != currentFocus) { IggyPlayerSetFocusRS(movie, hitObject, 0); } diff --git a/Minecraft.Client/Common/UI/UIScene.cpp b/Minecraft.Client/Common/UI/UIScene.cpp index 6ef6d0e82..07e383538 100644 --- a/Minecraft.Client/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Common/UI/UIScene.cpp @@ -900,6 +900,25 @@ void UIScene::sendInputToMovie(int key, bool repeat, bool pressed, bool released app.DebugPrintf("UI WARNING: Ignoring input as game action does not translate to an Iggy keycode\n"); return; } + +#ifdef _WINDOWS64 + // If a navigation key is pressed with no focused element, focus the first + // available one so arrow keys work even when the mouse is over empty space. + if(pressed && (iggyKeyCode == IGGY_KEYCODE_UP || iggyKeyCode == IGGY_KEYCODE_DOWN || + iggyKeyCode == IGGY_KEYCODE_LEFT || iggyKeyCode == IGGY_KEYCODE_RIGHT)) + { + IggyFocusHandle currentFocus = IGGY_FOCUS_NULL; + IggyFocusableObject focusables[64]; + S32 numFocusables = 0; + IggyPlayerGetFocusableObjects(swf, ¤tFocus, focusables, 64, &numFocusables); + if(currentFocus == IGGY_FOCUS_NULL && numFocusables > 0) + { + IggyPlayerSetFocusRS(swf, focusables[0].object, 0); + return; + } + } +#endif + IggyEvent keyEvent; // 4J Stu - Keyloc is always standard as we don't care about shift/alt IggyMakeEventKey( &keyEvent, pressed?IGGY_KEYEVENT_Down:IGGY_KEYEVENT_Up, (IggyKeycode)iggyKeyCode, IGGY_KEYLOC_Standard );