@@ -8,8 +8,10 @@ import com.lambda.client.util.graphics.VertexHelper
8
8
import com.lambda.client.util.graphics.font.FontRenderAdapter
9
9
import com.lambda.client.util.math.Vec2d
10
10
import com.lambda.client.util.math.Vec2f
11
+ import net.minecraft.client.gui.GuiScreen
11
12
import org.lwjgl.input.Keyboard
12
13
import kotlin.math.max
14
+ import kotlin.math.min
13
15
14
16
class StringButton (val setting : StringSetting ) : BooleanSlider(setting.name, 1.0 , setting.description, setting.visibility) {
15
17
@@ -61,18 +63,27 @@ class StringButton(val setting: StringSetting) : BooleanSlider(setting.name, 1.0
61
63
override fun onKeyInput (keyCode : Int , keyState : Boolean ) {
62
64
super .onKeyInput(keyCode, keyState)
63
65
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()
71
74
}
72
- else -> if (typedChar >= ' ' ) {
75
+ }
76
+ Keyboard .KEY_C -> {
77
+ if (GuiScreen .isCtrlKeyDown()) {
78
+ GuiScreen .setClipboardString(componentName)
79
+ } else {
73
80
componentName + = typedChar
74
81
}
75
82
}
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
76
87
}
77
88
}
78
89
0 commit comments