diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/component/StringButton.kt b/src/main/kotlin/com/lambda/client/gui/rgui/component/StringButton.kt index 0c7b24ff8..b0c2825d2 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/component/StringButton.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/component/StringButton.kt @@ -8,8 +8,10 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f +import net.minecraft.client.gui.GuiScreen import org.lwjgl.input.Keyboard import kotlin.math.max +import kotlin.math.min class StringButton(val setting: StringSetting) : BooleanSlider(setting.name, 1.0, setting.description, setting.visibility) { @@ -61,18 +63,27 @@ class StringButton(val setting: StringSetting) : BooleanSlider(setting.name, 1.0 override fun onKeyInput(keyCode: Int, keyState: Boolean) { super.onKeyInput(keyCode, keyState) val typedChar = Keyboard.getEventCharacter() - if (keyState) { - when (keyCode) { - Keyboard.KEY_RETURN -> { - onStopListening(true) - } - Keyboard.KEY_BACK, Keyboard.KEY_DELETE -> { - componentName = componentName.substring(0, max(componentName.length - 1, 0)) + if (!keyState) return + + when (keyCode) { + Keyboard.KEY_V, Keyboard.KEY_INSERT -> { + if (!GuiScreen.isCtrlKeyDown() && keyCode == Keyboard.KEY_V) { + componentName += typedChar + } else { + componentName += GuiScreen.getClipboardString().trim() } - else -> if (typedChar >= ' ') { + } + Keyboard.KEY_C -> { + if (GuiScreen.isCtrlKeyDown()) { + GuiScreen.setClipboardString(componentName) + } else { componentName += typedChar } } + Keyboard.KEY_RETURN -> onStopListening(true) + Keyboard.KEY_BACK -> componentName = componentName.dropLast(1) + Keyboard.KEY_DELETE -> componentName = "" + else -> if (typedChar >= ' ') componentName += typedChar } }