From 9b4c5aecbc5cfe18570b746e75e4b87d10e850e8 Mon Sep 17 00:00:00 2001 From: Dennis Fokin Date: Thu, 2 Mar 2023 14:40:47 +0100 Subject: [PATCH 1/2] Change from LogicalKeySet to SingleActivator --- lib/app/shortcuts.dart | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/app/shortcuts.dart b/lib/app/shortcuts.dart index 145249bd..c89f7744 100755 --- a/lib/app/shortcuts.dart +++ b/lib/app/shortcuts.dart @@ -71,9 +71,6 @@ class DeleteIntent extends Intent { const DeleteIntent(); } -final ctrlOrCmd = - Platform.isMacOS ? LogicalKeyboardKey.meta : LogicalKeyboardKey.control; - Widget registerGlobalShortcuts( {required WidgetRef ref, required Widget child}) => Actions( @@ -146,18 +143,23 @@ Widget registerGlobalShortcuts( }, child: Shortcuts( shortcuts: { - LogicalKeySet(ctrlOrCmd, LogicalKeyboardKey.keyC): const CopyIntent(), - LogicalKeySet(ctrlOrCmd, LogicalKeyboardKey.keyW): const HideIntent(), - LogicalKeySet(ctrlOrCmd, LogicalKeyboardKey.keyF): - const SearchIntent(), + SingleActivator(LogicalKeyboardKey.keyC, + meta: Platform.isMacOS, + control: !Platform.isMacOS): const CopyIntent(), + SingleActivator(LogicalKeyboardKey.keyW, + meta: Platform.isMacOS, + control: !Platform.isMacOS): const HideIntent(), + SingleActivator(LogicalKeyboardKey.keyF, + meta: Platform.isMacOS, + control: !Platform.isMacOS): const SearchIntent(), if (isDesktop) ...{ - LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.tab): + const SingleActivator(LogicalKeyboardKey.tab, control: true): const NextDeviceIntent(), }, if (Platform.isMacOS) ...{ - LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.keyQ): + const SingleActivator(LogicalKeyboardKey.keyQ, meta: true): const CloseIntent(), - LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.comma): + const SingleActivator(LogicalKeyboardKey.comma, meta: true): const SettingsIntent(), }, }, From f7fe129910c717b47d74c15bf51ba8dde4b98193 Mon Sep 17 00:00:00 2001 From: Dennis Fokin Date: Tue, 7 Mar 2023 11:03:31 +0100 Subject: [PATCH 2/2] Cleanup code --- lib/app/shortcuts.dart | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/app/shortcuts.dart b/lib/app/shortcuts.dart index c89f7744..c734d694 100755 --- a/lib/app/shortcuts.dart +++ b/lib/app/shortcuts.dart @@ -71,6 +71,10 @@ class DeleteIntent extends Intent { const DeleteIntent(); } +/// Use cmd on macOS, use ctrl on the other platforms +SingleActivator ctrlOrCmd(LogicalKeyboardKey key) => + SingleActivator(key, meta: Platform.isMacOS, control: !Platform.isMacOS); + Widget registerGlobalShortcuts( {required WidgetRef ref, required Widget child}) => Actions( @@ -143,15 +147,9 @@ Widget registerGlobalShortcuts( }, child: Shortcuts( shortcuts: { - SingleActivator(LogicalKeyboardKey.keyC, - meta: Platform.isMacOS, - control: !Platform.isMacOS): const CopyIntent(), - SingleActivator(LogicalKeyboardKey.keyW, - meta: Platform.isMacOS, - control: !Platform.isMacOS): const HideIntent(), - SingleActivator(LogicalKeyboardKey.keyF, - meta: Platform.isMacOS, - control: !Platform.isMacOS): const SearchIntent(), + ctrlOrCmd(LogicalKeyboardKey.keyC): const CopyIntent(), + ctrlOrCmd(LogicalKeyboardKey.keyW): const HideIntent(), + ctrlOrCmd(LogicalKeyboardKey.keyF): const SearchIntent(), if (isDesktop) ...{ const SingleActivator(LogicalKeyboardKey.tab, control: true): const NextDeviceIntent(),