Skip to content

Commit 36b02e5

Browse files
authored
Merge pull request #492 from Edouard127/gui_refactor_1
Added copy/paste in module options
2 parents 3a98b81 + e43e8ee commit 36b02e5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/main/kotlin/com/lambda/client/gui/rgui/component/StringButton.kt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import com.lambda.client.util.graphics.VertexHelper
88
import com.lambda.client.util.graphics.font.FontRenderAdapter
99
import com.lambda.client.util.math.Vec2d
1010
import com.lambda.client.util.math.Vec2f
11+
import net.minecraft.client.gui.GuiScreen
1112
import org.lwjgl.input.Keyboard
1213
import kotlin.math.max
14+
import kotlin.math.min
1315

1416
class 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

Comments
 (0)