From 07444d592fdb41371734056798e3a44e25b8a3e3 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Tue, 24 May 2022 10:47:44 +0200 Subject: Fix ctrl+v pasting twice (#148) --- .../moulberry/notenoughupdates/itemeditor/GuiElementTextField.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java index 95dbeccd..aa88cb77 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java @@ -212,6 +212,7 @@ public class GuiElementTextField extends GuiElement { if (focus) { //allows for pasting formatted text that includes "§" if (GuiScreen.isKeyComboCtrlV(keyCode)) { + textField.setEnabled(false); //The cursor position gets set to the end when using setText int oldCursorPosition = textField.getCursorPosition(); @@ -222,6 +223,8 @@ public class GuiElementTextField extends GuiElement { //writeText removes unwanted chars from the String which includes "§" textField.setText(stringBuilder.toString()); textField.setCursorPosition(oldCursorPosition + clipboardContent.length()); + } else { + textField.setEnabled(true); } if ((options & MULTILINE) != 0) { //Carriage return -- cgit