@@ -8,8 +8,10 @@ import com.lambda.client.util.graphics.VertexHelper
88import com.lambda.client.util.graphics.font.FontRenderAdapter
99import com.lambda.client.util.math.Vec2d
1010import com.lambda.client.util.math.Vec2f
11+ import net.minecraft.client.gui.GuiScreen
1112import org.lwjgl.input.Keyboard
1213import kotlin.math.max
14+ import kotlin.math.min
1315
1416class StringButton (val setting : StringSetting ) : BooleanSlider(setting.name, 1.0 , setting.description, setting.visibility) {
1517
@@ -61,18 +63,27 @@ class StringButton(val setting: StringSetting) : BooleanSlider(setting.name, 1.0
6163 override fun onKeyInput (keyCode : Int , keyState : Boolean ) {
6264 super .onKeyInput(keyCode, keyState)
6365 val typedChar = Keyboard .getEventCharacter()
64- if (keyState) {
65- when (keyCode) {
66- Keyboard .KEY_RETURN -> {
67- onStopListening(true )
68- }
69- Keyboard .KEY_BACK , Keyboard .KEY_DELETE -> {
70- componentName = componentName.substring(0 , max(componentName.length - 1 , 0 ))
66+ if (! keyState) return
67+
68+ when (keyCode) {
69+ Keyboard .KEY_V , Keyboard .KEY_INSERT -> {
70+ if (! GuiScreen .isCtrlKeyDown() && keyCode == Keyboard .KEY_V ) {
71+ componentName + = typedChar
72+ } else {
73+ componentName + = GuiScreen .getClipboardString().trim()
7174 }
72- else -> if (typedChar >= ' ' ) {
75+ }
76+ Keyboard .KEY_C -> {
77+ if (GuiScreen .isCtrlKeyDown()) {
78+ GuiScreen .setClipboardString(componentName)
79+ } else {
7380 componentName + = typedChar
7481 }
7582 }
83+ Keyboard .KEY_RETURN -> onStopListening(true )
84+ Keyboard .KEY_BACK -> componentName = componentName.dropLast(1 )
85+ Keyboard .KEY_DELETE -> componentName = " "
86+ else -> if (typedChar >= ' ' ) componentName + = typedChar
7687 }
7788 }
7889
0 commit comments