press() and actions.ts: what the mouse offers, from one place
press(key) sends a synthetic keydown through the page's key handler, so a mouse control does exactly what its key does. actions.ts builds the items of the selection bar, the ⋯ menus and the right-click menu from a context for each kind of target (words, a node, a page, a pane, an article's row, the top bar); each item names its key and runs by pressing it, or runs a command of the command bar. Unit tests check every item presses its own key and that the key handler takes that key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
abf79c14cc
commit
9b73cdb15e
3 files changed
+443
No files matched your search
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* The one way a mouse control acts: it presses the key it names. A synthetic keydown goes to the
|
||||
* window, where the page's key handler (keys.ts `handleKey`, listened for by App.tsx) takes it as
|
||||
* it takes a real one, so a button, a menu item or the selection bar does exactly what its key does
|
||||
* and no action has a second implementation.
|
||||
*/
|
||||
export function press(key: string, shift = false) {
|
||||
window.dispatchEvent(new KeyboardEvent("keydown", { key, shiftKey: shift, bubbles: true, cancelable: true }));
|
||||
}
|
||||
Reference in new issue
Block a user