From 8464ca94b6c3334863c1b14f135698cda9bedb87 Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Fri, 16 Feb 2024 23:01:02 +0100 Subject: [PATCH] Don't unfocus textbox while pressing tab --- src/window_callbacks.cpp | 5 ++++- src/window_callbacks.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/window_callbacks.cpp b/src/window_callbacks.cpp index 2c082a21..461f9bb9 100644 --- a/src/window_callbacks.cpp +++ b/src/window_callbacks.cpp @@ -215,10 +215,13 @@ void WindowCallbacks::onKeyboard(KeyCode key, KeyAction action) { return; } - if(action == KeyAction::PRESS && jniSupport.getTextInputHandler().isEnabled() && !jniSupport.getTextInputHandler().isMultiline() && (key == KeyCode::TAB || key == KeyCode::UP || key == KeyCode::DOWN)) { + + if(action == KeyAction::PRESS && jniSupport.getTextInputHandler().isEnabled() && !jniSupport.getTextInputHandler().isMultiline() && (lastKey == KeyCode::TAB || lastKey == KeyCode::UP || lastKey == KeyCode::DOWN) && !(key == KeyCode::TAB || key == KeyCode::UP || key == KeyCode::DOWN)) { jniSupport.onBackPressed(); } + lastKey = key; + if(action == KeyAction::PRESS) inputQueue.addEvent(FakeKeyEvent(AKEY_EVENT_ACTION_DOWN, mapMinecraftToAndroidKey(key))); else if(action == KeyAction::RELEASE) diff --git a/src/window_callbacks.h b/src/window_callbacks.h index d60df383..77339714 100644 --- a/src/window_callbacks.h +++ b/src/window_callbacks.h @@ -21,6 +21,7 @@ class WindowCallbacks { FakeInputQueue &inputQueue; std::unordered_map gamepads; int32_t buttonState = 0; + KeyCode lastKey = (KeyCode)0; bool useDirectMouseInput, useDirectKeyboardInput; bool modCTRL = false; bool needsQueueGamepadInput = true;