dialog tab order

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages 2023-01-16 20:58:42 +08:00
parent cc0f4509a7
commit d793fa64a3

View File

@ -613,8 +613,9 @@ class CustomAlertDialog extends StatelessWidget {
Future.delayed(Duration.zero, () {
if (!focusNode.hasFocus) focusNode.requestFocus();
});
return Focus(
focusNode: focusNode,
FocusScopeNode scopeNode = FocusScopeNode();
return FocusScope(
node: scopeNode,
autofocus: true,
onKey: (node, key) {
if (key.logicalKey == LogicalKeyboardKey.escape) {
@ -626,6 +627,11 @@ class CustomAlertDialog extends StatelessWidget {
key.logicalKey == LogicalKeyboardKey.enter) {
if (key is RawKeyDownEvent) onSubmit?.call();
return KeyEventResult.handled;
} else if (key.logicalKey == LogicalKeyboardKey.tab) {
if (key is RawKeyDownEvent) {
scopeNode.nextFocus();
}
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
},