-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/engine
#40706Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9Found to occur in 3.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-macBuilding on or for macOS specificallyBuilding on or for macOS specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
- Create a
control + tabkeyboard shortcut with LogicalKeySet and/or SingleActivator on macOS. See code sample for an example. - Notice that nothing happens when the keys are pressed.
- Try other combinations and note that they work, such as
tab + shift. - Remove the comment around the TextField in the sample.
- Move to to the TextField, for example with arrow keys or tab.
- Now try the shortcuts again. This time
control + tabworks. But as soon as you move away from the TextField it stops working.
In the code sample I have demonstrated this behavior with both SingleActivator and LogicalKeyset.
This works as expected on Windows. The shortcut ctrl + tab works everywhere. For some reason there is an issue on macOS.
Expected results:
That I can create a keyboard shortcut for control + tab everywhere, not just in a textfield, for macOS.
Actual results:
I cannot create a proper keyboard shortcut for control + tab (on macOS), but for some reason it works when I am in a textfield. I can create a shortcut for many other combinations containing the tab key, for example tab + shift. This is demonstrated in the sample code.
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class ActivatorIntent extends Intent {
const ActivatorIntent();
}
class KeySetIntent extends Intent {
const KeySetIntent();
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Shortcuts(
shortcuts: {
SingleActivator(LogicalKeyboardKey.tab, control: true):
ActivatorIntent(),
SingleActivator(LogicalKeyboardKey.tab, shift: true):
ActivatorIntent(),
/*LogicalKeySet(LogicalKeyboardKey.tab, LogicalKeyboardKey.control):
KeySetIntent(),
LogicalKeySet(LogicalKeyboardKey.tab, LogicalKeyboardKey.shift):
KeySetIntent(),*/
},
child: Actions(
actions: {
ActivatorIntent: CallbackAction<ActivatorIntent>(onInvoke: (_) {
debugPrint('ActivatorIntent shortcut activated');
return null;
}),
KeySetIntent: CallbackAction<KeySetIntent>(onInvoke: (_) {
debugPrint('KeySetIntent shortcut activated');
return null;
})
},
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 18.0),
child: Column(
children: [
ElevatedButton(
onPressed: () {
debugPrint('a');
},
child: const Text('Button 1'),
),
//TextField(),
ElevatedButton(
onPressed: () {
debugPrint('b');
},
child: const Text('Button 2'),
),
],
),
),
),
)));
}
}
Logs
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: desktopRunning on desktopRunning on desktopengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: focusFocus traversal, gaining or losing focusFocus traversal, gaining or losing focusfound in release: 3.7Found to occur in 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9Found to occur in 3.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-macBuilding on or for macOS specificallyBuilding on or for macOS specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Type
Projects
Status
Done (PR merged)