Always passing all keyboard events to OS
This commit is contained in:
parent
0a60d472ea
commit
244126ee9e
4 changed files with 8 additions and 10 deletions
|
|
@ -96,7 +96,6 @@ textInput = config \ ui.stateful {
|
|||
# update : State \ Event \ State
|
||||
update = state event \ event
|
||||
| Key { key = c, printable = True } \
|
||||
_ = debug "text keydown" c;
|
||||
newText = insertChar state.text state.cursorPos c;
|
||||
newCursorPos = state.cursorPos + 1;
|
||||
newScroll = calcScrollOffset newText newCursorPos state.scrollOffset config.w;
|
||||
|
|
|
|||
|
|
@ -52,9 +52,7 @@ palette = config \
|
|||
w = contentWidth,
|
||||
h = textInputHeight,
|
||||
onChange = text \ batch [config.state.query := text, config.state.focusedIndex := 0],
|
||||
onKeyDown = key \
|
||||
_ = debug "palette key" key;
|
||||
key
|
||||
onKeyDown = key \ key
|
||||
| "ArrowUp" \ config.state.focusedIndex := max 0 (config.state.focusedIndex - 1)
|
||||
| "ArrowDown" \ config.state.focusedIndex := (config.state.focusedIndex + 1)
|
||||
| "Enter" \ (\ config.onSelect (unwrapOr "" (nth config.state.focusedIndex results)))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
osState = {
|
||||
palette = {
|
||||
visible = True,
|
||||
visible = False,
|
||||
query = "",
|
||||
focusedIndex = 0,
|
||||
},
|
||||
|
|
@ -9,8 +9,7 @@ osState = {
|
|||
init = {};
|
||||
|
||||
update = state event \ event
|
||||
| Key { key = "p", meta = True } \ togglePalette
|
||||
| Key { key = k } \ debug "key" k
|
||||
| Key { key = "p", meta = True } \ osState.palette.visible := not (osState.palette.visible)
|
||||
| _ \ state;
|
||||
|
||||
view = state viewport \
|
||||
|
|
@ -24,7 +23,7 @@ view = state viewport \
|
|||
onSelect = item \ (debug "selected" item),
|
||||
viewport = viewport,
|
||||
}
|
||||
| False \ text { content = "" }
|
||||
| False \ ui.text { content = "" }
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -217,11 +217,13 @@ export function runAppCompiled(app: App, canvas: HTMLCanvasElement, rt: any) {
|
|||
}
|
||||
};
|
||||
|
||||
// always send to OS first
|
||||
handleEvent(event);
|
||||
|
||||
if (focusedComponentKey) {
|
||||
handleComponentEvent(focusedComponentKey, event);
|
||||
} else {
|
||||
handleEvent(event);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue