Skip to content

Commit 231e5cc

Browse files
committed
Allowing editor to handle key events when in focus chain but lacking primary focus
1 parent 92fd60d commit 231e5cc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

super_editor/lib/src/default_editor/document_hardware_keyboard/document_physical_keyboard.dart

+9-8
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ class _SuperEditorHardwareKeyHandlerState extends State<SuperEditorHardwareKeyHa
6969
}
7070

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

0 commit comments

Comments
 (0)