From b8361a9514c6ddefc3e8b07e39854769b6c73582 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Thu, 9 Dec 2021 19:08:20 +0900 Subject: [PATCH] text input: fixed a bug where pasting would advance the internal cursor but the actual text wouldn't go in --- src/net/torvald/terrarum/ui/UIItemTextLineInput.kt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt index fbf6cb402..1c44368fa 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt @@ -280,6 +280,11 @@ class UIItemTextLineInput( tryCursorBack() } } + else if (keycodes.containsSome(Input.Keys.ENTER, Input.Keys.NUMPAD_ENTER)) { + endComposing() + + println("END COMPOSING!!") + } // accept: // - literal "<" // - keysymbol that does not start with "<" (not always has length of 1 because UTF-16) @@ -321,13 +326,13 @@ class UIItemTextLineInput( moveCursorToEnd(codepoints.size) } } - else if (keycodes.containsSome(Input.Keys.ENTER, Input.Keys.NUMPAD_ENTER)) { - endComposing() - } // don't put innards of tryCursorBack/Forward here -- you absolutely don't want that behaviour } } + catch (e: IndexOutOfBoundsException) { + e.printStackTrace() + } catch (e: NullPointerException) { e.printStackTrace() } @@ -341,6 +346,7 @@ class UIItemTextLineInput( } fboUpdateLatch = true + } override fun update(delta: Float) { @@ -418,6 +424,7 @@ class UIItemTextLineInput( actuallyInserted.removeAt(0) + textbuf.addAll(actuallyInserted) moveCursorToEnd(actuallyInserted.size) tryCursorBack()