From 9ec08e0af8ba7c8dae542125b27544211ba898c0 Mon Sep 17 00:00:00 2001 From: MrTheShy <49885496+MrTheShy@users.noreply.github.com> Date: Thu, 5 Mar 2026 21:17:36 +0100 Subject: [PATCH] Sync keyboard text buffer from Flash before processing physical input The native keyboard scene maintained a separate C++ buffer (m_win64TextBuffer) for physical keyboard input, which was pushed to the Flash text field via setLabel(). However, when the user typed with the on-screen controller buttons, Flash updated its text field directly through ActionScript without updating the C++ buffer. This caused a desync: switching back to the physical keyboard would overwrite any text entered via controller, since m_win64TextBuffer still held the old value before the controller edits. Fix: read the current Flash text field into m_win64TextBuffer at the start of each tick(), before consuming new physical keyboard chars. This ensures both input methods always operate on the same state. --- Minecraft.Client/Common/UI/UIScene_Keyboard.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp index 9e46a42e9..b28564c3a 100644 --- a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp +++ b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp @@ -163,6 +163,12 @@ void UIScene_Keyboard::tick() { UIScene::tick(); + // Sync our buffer from Flash so we pick up changes made via controller/on-screen buttons. + // Without this, switching between controller and keyboard would use stale text. + const wchar_t* flashText = m_KeyboardTextInput.getLabel(); + if (flashText) + m_win64TextBuffer = flashText; + // Accumulate physical keyboard chars into our own buffer, then push to Flash via setLabel. // This bypasses Iggy's focus system (char events only route to the focused element). // The char buffer is cleared on open so Enter/clicks from the triggering action don't leak in.