aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/InputWithHistory.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-01-24 13:12:58 +0300
committerRblSb <msrblsb@gmail.com>2021-01-24 13:12:58 +0300
commit35beab11cdccf09dc77917a795b033314e62a5b1 (patch)
tree23134d53f46ac678742f7fc4095b66dd68010617 /src/client/InputWithHistory.hx
parent3444b413ab12783c85ce73df9931142fea11b749 (diff)
Video title input
Diffstat (limited to 'src/client/InputWithHistory.hx')
-rw-r--r--src/client/InputWithHistory.hx21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/client/InputWithHistory.hx b/src/client/InputWithHistory.hx
index ecba43a..c4e8bf4 100644
--- a/src/client/InputWithHistory.hx
+++ b/src/client/InputWithHistory.hx
@@ -29,8 +29,9 @@ class InputWithHistory {
}
function onKeyDown(e:KeyboardEvent) {
- switch (e.keyCode) {
- case 13: // Enter
+ final key:KeyCode = cast e.keyCode;
+ switch (key) {
+ case Return:
final value = element.value;
if (value.length == 0) return;
final isAdd = onEnter(value);
@@ -38,23 +39,31 @@ class InputWithHistory {
if (history.length > maxItems) history.shift();
historyId = -1;
element.value = "";
- case 38: // Up
+ onInput();
+ case Up:
historyId--;
if (historyId == -2) {
historyId = history.length - 1;
if (historyId == -1) return;
} else if (historyId == -1) historyId++;
element.value = history[historyId];
- case 40: // Down
+ onInput();
+ case Down:
if (historyId == -1) return;
historyId++;
if (historyId > history.length - 1) {
historyId = -1;
element.value = "";
- return;
+ } else {
+ element.value = history[historyId];
}
- element.value = history[historyId];
+ onInput();
+ default:
}
}
+ function onInput():Void {
+ if (element.oninput != null) element.oninput();
+ }
+
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage