diff --git a/mod/ovis-composer/main.js b/mod/ovis-composer/main.js index 2d6ae28..5549abe 100644 --- a/mod/ovis-composer/main.js +++ b/mod/ovis-composer/main.js @@ -124,28 +124,29 @@ export default class Composer extends View { }); this.handle = cx.focus_handle(); - // The keys the field swallows: it binds the arrows to the movement of the - // cursor, and it eats them before they reach the element. Ctrl+C is not - // bound here - it stays "copy". The composer takes them as actions of its own - the app hands - // every action named "." to the mod's nextCommand(). + // The keys the field swallows: it binds the arrows and Tab to its own + // actions and eats them before they reach the element. Ctrl+C is not bound + // here - it stays "copy". The composer takes these keys as actions of its + // own - the app hands every action named "." to the mod's + // nextCommand(). // - // The bindings sit on the "Input" context - the context of a text field - - // so they only ever fire where a field has the keyboard. The composer's - // own actions are bound deeper than the field's own ones, so the field's - // actions would win and the composer would never hear of the key; the - // composer therefore gets the key first and the field gets what is left. + // The keymap is application-wide, so a plain "Input" context would also + // match the text fields of other mods and swallow their keys. The + // bindings use the descendant predicate "ovis-composer > Input": only a + // field that sits inside the composer's own key context (see + // key_context(CONTEXT) on the root) matches. // // What the composer does with the key depends on the keyboard: only the // copy of the composer whose own field has the keyboard acts - the other // copies (a composer in another pane) leave the key alone. cx.bind_keys([ - { keystroke: "up", action: "ovis-composer.up", context: "Input" }, - { keystroke: "down", action: "ovis-composer.down", context: "Input" }, - { keystroke: "tab", action: "ovis-composer.accept", context: "Input" }, - { keystroke: "ctrl-r", action: "ovis-composer.panel", context: "Input" }, - { keystroke: "ctrl-enter", action: "ovis-composer.send_now", context: "Input" }, - { keystroke: "alt-enter", action: "ovis-composer.hold", context: "Input" }, - { keystroke: "escape", action: "ovis-composer.escape", context: "Input" }, + { keystroke: "up", action: "ovis-composer.up", context: `${CONTEXT} > Input` }, + { keystroke: "down", action: "ovis-composer.down", context: `${CONTEXT} > Input` }, + { keystroke: "tab", action: "ovis-composer.accept", context: `${CONTEXT} > Input` }, + { keystroke: "ctrl-r", action: "ovis-composer.panel", context: `${CONTEXT} > Input` }, + { keystroke: "ctrl-enter", action: "ovis-composer.send_now", context: `${CONTEXT} > Input` }, + { keystroke: "alt-enter", action: "ovis-composer.hold", context: `${CONTEXT} > Input` }, + { keystroke: "escape", action: "ovis-composer.escape", context: `${CONTEXT} > Input` }, ]); // Focus follows the click: nothing here takes the keyboard on its own.