aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/InputWithHistory.hx
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-10-19 15:32:53 -0700
committerPinapelz <yukais@pinapelz.com>2026-10-19 15:32:53 -0700
commit304bd1e77a5442f614aacd2b35f330777118b2cd (patch)
tree970e7da13bb1bd8edf1f9b453af4d0994c665e94 /src/client/InputWithHistory.hx
parenta4f3064542ddad6939598e7e60ca0090be07df60 (diff)
merge with upstream https://github.com/RblSb/SyncTubeHEADmaster
Diffstat (limited to 'src/client/InputWithHistory.hx')
-rw-r--r--src/client/InputWithHistory.hx11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/client/InputWithHistory.hx b/src/client/InputWithHistory.hx
index e41ec16..c82267f 100644
--- a/src/client/InputWithHistory.hx
+++ b/src/client/InputWithHistory.hx
@@ -1,5 +1,6 @@
package client;
+import js.html.Event;
import js.html.InputElement;
import js.html.KeyboardEvent;
@@ -8,19 +9,22 @@ class InputWithHistory {
final maxItems:Int;
final history:Array<String>;
final onEnter:(value:String) -> Bool;
+ final onInterceptKeyDown:Null<(e:KeyboardEvent) -> Bool>;
var historyId = -1;
public function new(
element:InputElement,
?history:Array<String>,
maxItems:Int,
- onEnter:(value:String) -> Bool
+ onEnter:(value:String) -> Bool,
+ ?onInterceptKeyDown:(e:KeyboardEvent) -> Bool
) {
this.element = element;
if (history != null) this.history = history;
else this.history = [];
this.maxItems = maxItems;
this.onEnter = onEnter;
+ this.onInterceptKeyDown = onInterceptKeyDown;
element.onkeydown = onKeyDown;
}
@@ -30,6 +34,7 @@ class InputWithHistory {
}
function onKeyDown(e:KeyboardEvent) {
+ if (onInterceptKeyDown != null && onInterceptKeyDown(e)) return;
final key:KeyCode = cast e.keyCode;
switch (key) {
case Return:
@@ -59,11 +64,13 @@ class InputWithHistory {
element.value = history[historyId];
}
onInput();
+ case Escape:
+ e.preventDefault();
default:
}
}
function onInput():Void {
- if (element.oninput != null) element.oninput();
+ element.dispatchEvent(new Event("input"));
}
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage