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
Arrow (also D-PAD) keys don't work for focus traversal of TextFormField #49335
Comments
This is partially a duplicate of #47156 (the tab key shouldn't be entered when moving to the next field). When I run this, both Tab and Shift-Tab function as expected for me, except for adding the tab to the field. The DPAD navigation doesn't work because the DPAD input is interpreted as arrow key presses, and arrow keys on text fields move the cursor, not the focus. I agree that there should be a way to select this behavior, of course, and there isn't currently. Once we've converted the text fields to use |
You can solve this (partially) by supplying different default shortcuts for the class TestApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
shortcuts: Map<LogicalKeySet, Intent>.from(WidgetsApp.defaultShortcuts)..addAll(<LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.arrowLeft): const DirectionalFocusIntent(TraversalDirection.left, ignoreTextFields: false),
LogicalKeySet(LogicalKeyboardKey.arrowRight): const DirectionalFocusIntent(TraversalDirection.right, ignoreTextFields: false),
LogicalKeySet(LogicalKeyboardKey.arrowDown): const DirectionalFocusIntent(TraversalDirection.down, ignoreTextFields: false),
LogicalKeySet(LogicalKeyboardKey.arrowUp): const DirectionalFocusIntent(TraversalDirection.up, ignoreTextFields: false),
}),
home: Scaffold(
appBar: AppBar(
title: Text('Test App'),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(8.0),
child: TestWidget(),
),
),
);
}
} I say "partially", because it will still try and move the cursor inside the text field when you move to the next field unless they are single line fields where you're only moving vertically (like in your example). |
You can see that I noticed that the But I do need support for focus navigation using arrow (and D-PAD) keys. Since |
Shift+Tab is not expected to work in an emulator, because it doesn't set the modifier bits on key events properly. It will work on a device. The remaining issues in this bug are a duplicate of #47156, so I'm going to close this issue. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Thanks for the awesome framework.
I'm developing an app which should work on both Android mobile devices as well as Android TVs. I'm facing some issue while implementing login and signup forms.
Steps to Reproduce
flutter create testpad
.main.dart
as follows:Expected results:
The focus should move to both next and previous fields on various key press events of keyboard and TV remotes, as it works as expected for focus traversal between other focusable widgets.
Also, when moving focus with
Tab
key, then the white-space is added to input field, which should not be the case.Actual results:
The focus moves to next field with
Tab
key but previous field is not getting focus whenShift+Tab
is pressed. Also neither arrow keys nor Android TV remote D-PAD keys works for focus traversal ofTextFormField
but works fine for other focusable widgets.Logs
The text was updated successfully, but these errors were encountered: