-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat: Add verbosity shortcuts (experimental) #9481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a92283a
6a7e5e0
ad95469
1bb3537
8baacc2
6d0418e
1d4e167
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import {isDeletable as isIDeletable} from './interfaces/i_deletable.js'; | |
| import {isDraggable} from './interfaces/i_draggable.js'; | ||
| import {IFocusableNode} from './interfaces/i_focusable_node.js'; | ||
| import {KeyboardShortcut, ShortcutRegistry} from './shortcut_registry.js'; | ||
| import {aria} from './utils.js'; | ||
| import {Coordinate} from './utils/coordinate.js'; | ||
| import {KeyCodes} from './utils/keycodes.js'; | ||
| import {Rect} from './utils/rect.js'; | ||
|
|
@@ -33,6 +34,8 @@ export enum names { | |
| PASTE = 'paste', | ||
| UNDO = 'undo', | ||
| REDO = 'redo', | ||
| READ_FULL_BLOCK_SUMMARY = 'read_full_block_summary', | ||
| READ_BLOCK_PARENT_SUMMARY = 'read_block_parent_summary', | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -386,6 +389,71 @@ export function registerRedo() { | |
| ShortcutRegistry.registry.register(redoShortcut); | ||
| } | ||
|
|
||
| /** | ||
| * Registeres a keyboard shortcut for re-reading the current selected block's | ||
| * summary with additional verbosity to help provide context on where the user | ||
| * is currently navigated (for screen reader users only). | ||
| */ | ||
| export function registerReadFullBlockSummary() { | ||
| const i = ShortcutRegistry.registry.createSerializedKey(KeyCodes.I, null); | ||
| const readFullBlockSummaryShortcut: KeyboardShortcut = { | ||
| name: names.READ_FULL_BLOCK_SUMMARY, | ||
| preconditionFn(workspace) { | ||
| return ( | ||
| !workspace.isDragging() && | ||
| !getFocusManager().ephemeralFocusTaken() && | ||
| !!getFocusManager().getFocusedNode() && | ||
| getFocusManager().getFocusedNode() instanceof BlockSvg | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shortcut should work for fields, connections, and icons too. The idea is that you can get information about the block without having to change your focus. This can help you figure out what to type into a field, for example. I know you have a lot in flight right now though so it may make more sense to come back to this as a follow up (or pass to Aaron) in order to at least get the base version submitted.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep I agree, and that's part of why this isn't fully resolving RaspberryPiFoundation/blockly-keyboard-experimentation#764. I'll reference this comment there so that this context isn't lost, and I'm happy for @gonfunko to take over that issue if he has bandwidth to continue chipping away at the other parts of it. |
||
| ); | ||
| }, | ||
| callback(_, e) { | ||
| const selectedBlock = getFocusManager().getFocusedNode() as BlockSvg; | ||
| const blockSummary = selectedBlock.computeAriaLabel(true); | ||
| aria.announceDynamicAriaState(`Current block: ${blockSummary}`); | ||
| e.preventDefault(); | ||
| return true; | ||
| }, | ||
| keyCodes: [i], | ||
| }; | ||
| ShortcutRegistry.registry.register(readFullBlockSummaryShortcut); | ||
| } | ||
|
|
||
| /** | ||
| * Registeres a keyboard shortcut for re-reading the current selected block's | ||
| * parent block summary with additional verbosity to help provide context on | ||
| * where the user is currently navigated (for screen reader users only). | ||
| */ | ||
| export function registerReadBlockParentSummary() { | ||
| const shiftI = ShortcutRegistry.registry.createSerializedKey(KeyCodes.I, [ | ||
| KeyCodes.SHIFT, | ||
| ]); | ||
| const readBlockParentSummaryShortcut: KeyboardShortcut = { | ||
| name: names.READ_BLOCK_PARENT_SUMMARY, | ||
| preconditionFn(workspace) { | ||
| return ( | ||
| !workspace.isDragging() && | ||
| !getFocusManager().ephemeralFocusTaken() && | ||
| !!getFocusManager().getFocusedNode() && | ||
| getFocusManager().getFocusedNode() instanceof BlockSvg | ||
| ); | ||
| }, | ||
| callback(_, e) { | ||
| const selectedBlock = getFocusManager().getFocusedNode() as BlockSvg; | ||
| const parentBlock = selectedBlock.getParent(); | ||
| if (parentBlock) { | ||
| const blockSummary = parentBlock.computeAriaLabel(true); | ||
| aria.announceDynamicAriaState(`Parent block: ${blockSummary}`); | ||
| } else { | ||
| aria.announceDynamicAriaState('Current block has no parent'); | ||
| } | ||
| e.preventDefault(); | ||
| return true; | ||
| }, | ||
| keyCodes: [shiftI], | ||
| }; | ||
| ShortcutRegistry.registry.register(readBlockParentSummaryShortcut); | ||
| } | ||
|
|
||
| /** | ||
| * Registers all default keyboard shortcut item. This should be called once per | ||
| * instance of KeyboardShortcutRegistry. | ||
|
|
@@ -400,6 +468,8 @@ export function registerDefaultShortcuts() { | |
| registerPaste(); | ||
| registerUndo(); | ||
| registerRedo(); | ||
| registerReadFullBlockSummary(); | ||
| registerReadBlockParentSummary(); | ||
| } | ||
|
|
||
| registerDefaultShortcuts(); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Registers (typo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.