fixed text input

This commit is contained in:
Andrew Gundersen 2021-03-22 09:53:13 -05:00
commit 7bb0bda756
3 changed files with 19 additions and 7 deletions

View file

@ -97,6 +97,14 @@ export default function useTextInputController(elementX: Ref) {
} }
} }
// Keys that are capable of opening the text input.
const hotKeyRange = keyboardNameMap.slice(47, 91)
const isHotKey = (key: string) => {
if (hotKeyRange.includes(key)) {
return true
}
}
//---Callbacks----------------------------------------------- //---Callbacks-----------------------------------------------
const onKeyDown = (e: KeyboardEvent) => { const onKeyDown = (e: KeyboardEvent) => {
@ -104,16 +112,20 @@ export default function useTextInputController(elementX: Ref) {
if (textInput) { if (textInput) {
// First-key handler. // Only runs on firstKey.
if (firstKey) { if (firstKey) {
if (key == "SPACE") return
if (!isHotKey(key)) {
return
}
prepInput() prepInput()
} }
textInput.focus(); textInput.focus();
// Close input when no text or on ESC. // Close input when no text or on ESC.
if (textInput.value == "" && !firstKey) { if ((textInput.value == "") && (!firstKey) && (key === "BACK_SPACE")) {
clearInput() clearInput()
return return
} }
@ -138,7 +150,7 @@ export default function useTextInputController(elementX: Ref) {
//----------------------------------------------------------- //-----------------------------------------------------------
// Watch parent position and update side. // Watch parent position and update side.
watch(elementX, (elementX, previous) => { watch(elementX, (elementX, _previous) => {
const winW = window.innerWidth const winW = window.innerWidth
// Logic depends on the side we are on. // Logic depends on the side we are on.

View file

@ -83,7 +83,7 @@ export default function useMessages() {
if (messages.value.size >= 200) { if (messages.value.size >= 200) {
const oldest = Array.from(messages.value.keys()).shift(); const oldest = Array.from(messages.value.keys()).shift();
messages.value.delete(oldest); messages.value.delete(oldest);
}; }
// Step 4: Update grouping. // Step 4: Update grouping.
updateGrouping() updateGrouping()
@ -100,4 +100,4 @@ export default function useMessages() {
messages, messages,
updateMessageView updateMessageView
} }
}; }

View file

@ -1 +1 @@
{"w":735,"h":510,"x":1354,"y":513} {"w":735,"h":510,"x":944,"y":489}