From 60dd2eacb2a5d466e05b7fa62158ae8871fab60d Mon Sep 17 00:00:00 2001 From: RMS Date: Sun, 23 Aug 2026 17:07:27 -0600 Subject: [PATCH] input field changes --- src/gui/input-field/input-field.ts | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/gui/input-field/input-field.ts b/src/gui/input-field/input-field.ts index 665369b..9a2aca0 100644 --- a/src/gui/input-field/input-field.ts +++ b/src/gui/input-field/input-field.ts @@ -25,6 +25,9 @@ declare global { cursor: InputFieldCursor obscure: boolean obscureChar: string + tabDirection: "right" | "down"; + maxLength: number; + onEnterPressedCallback?: (this: this) => void; calculateCursorPos(this: this): number getValueAsString(this: this): string @@ -70,6 +73,8 @@ modmanager.gui.InputField = ig.FocusGui.extend({ cursor: undefined, obscure: false, obscureChar: '*', + tabDirection: "down", + maxLength: 100, init(width: number, height: number, type?: modmanager.gui.InputFieldType, obscure?: boolean, obscureChar?: string) { this.parent(true) this.setSize(width, height) @@ -145,6 +150,46 @@ modmanager.gui.InputField = ig.FocusGui.extend({ case 'End': this.cursorPos = this.value.length break + case "Enter": + this.onEnterPressedCallback?.(); + break; + case "ArrowDown": + this.buttonGroup.stepDown(); + break; + case "ArrowUp": + this.buttonGroup.stepUp(); + break; + case "Tab": + if (this.tabDirection == 'down') { + if (event.shiftKey) { + this.buttonGroup.stepUp(); + } else { + this.buttonGroup.stepDown(); + } + } else { + if (event.shiftKey) { + this.buttonGroup.stepLeft(); + } else { + this.buttonGroup.stepRight(); + } + } + break; + case "v": + if (event.ctrlKey) { + navigator.clipboard.readText().then(text => { + this.setText(text.substring(0, this.maxLength)); + }) + .catch(err => { + console.error("Could not read from clipboard:"); + console.error(err); + }); + } + break; + case "u": + if (event.ctrlKey) { + this.setText(""); + } + break; default: { let old = this.getValueAsString()