Skip to content

Commit

Permalink
Allowing editor to handle key events when in focus chain but lacking …
Browse files Browse the repository at this point in the history
…primary focus
  • Loading branch information
jmatth committed Aug 14, 2024
1 parent 3a54047 commit b9f210f
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ class _SuperEditorHardwareKeyHandlerState extends State<SuperEditorHardwareKeyHa
}

KeyEventResult _onKeyPressed(FocusNode node, KeyEvent keyEvent) {
if (!node.hasPrimaryFocus) {
// The editor is focused, but doesn't have primary focus. For example:
// - The editor has a node with a focused widget.
// - There is a focused widget somewhere else in the tree which shares
// focus with the editor, typically a popover toolbar.
// Don't run any of the editor key handlers and let the event bubble up.
return KeyEventResult.ignored;
}
// if (!node.hasPrimaryFocus) {
// // The editor is focused, but doesn't have primary focus. For example:
// // - The editor has a node with a focused widget.
// // - There is a focused widget somewhere else in the tree which shares
// // focus with the editor, typically a popover toolbar.
// // Don't run any of the editor key handlers and let the event bubble up.
// return KeyEventResult.ignored;
// }
editorKeyLog.info("Handling key press: $keyEvent");
ExecutionInstruction instruction = ExecutionInstruction.continueExecution;
int index = 0;
Expand All @@ -100,6 +100,7 @@ class _SuperEditorHardwareKeyHandlerState extends State<SuperEditorHardwareKeyHa
@override
Widget build(BuildContext context) {
return Focus(
debugLabel: 'SuperEditorHardwareKeyHandler',
focusNode: _focusNode,
onKeyEvent: widget.keyboardActions.isEmpty ? null : _onKeyPressed,
autofocus: widget.autofocus,
Expand Down

0 comments on commit b9f210f

Please sign in to comment.