Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added copy/paste in module options #492

Merged
merged 5 commits into from
May 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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
}
}

Expand Down