feat(studio): Cmd+S / Cmd+Enter shortcuts in flow editor
Some checks are pending
Security / Security check (push) Waiting to run
Some checks are pending
Security / Security check (push) Waiting to run
Wraps the FlowEditorPage in Shortcuts/Actions so Cmd+S (or Ctrl+S) saves and Cmd+Enter (or Ctrl+Enter) runs the active flow, no matter whether the code field or toolbar has focus. Matches the rest of Studio's keyboard- first ethos. Disabled when no flow is open or an operation is already in progress. Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
parent
bb793e64a9
commit
c3f9f862ab
1 changed files with 45 additions and 0 deletions
|
|
@ -253,6 +253,43 @@ outputs:
|
|||
final l = AppLocalizations.of(context)!;
|
||||
final theme = Theme.of(context);
|
||||
|
||||
// Cmd+S / Ctrl+S → save, Cmd+Enter / Ctrl+Enter → run.
|
||||
// We layer the Shortcuts widget at the page root so the
|
||||
// bindings work whether the editor area has focus or not.
|
||||
final shortcuts = <ShortcutActivator, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.keyS):
|
||||
const _SaveIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyS):
|
||||
const _SaveIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.meta, LogicalKeyboardKey.enter):
|
||||
const _RunIntent(),
|
||||
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.enter):
|
||||
const _RunIntent(),
|
||||
};
|
||||
|
||||
return Shortcuts(
|
||||
shortcuts: shortcuts,
|
||||
child: Actions(
|
||||
actions: <Type, Action<Intent>>{
|
||||
_SaveIntent: CallbackAction<_SaveIntent>(
|
||||
onInvoke: (_) {
|
||||
if (_activeName != null && !_saving) _save();
|
||||
return null;
|
||||
},
|
||||
),
|
||||
_RunIntent: CallbackAction<_RunIntent>(
|
||||
onInvoke: (_) {
|
||||
if (_activeName != null && !_running) _run();
|
||||
return null;
|
||||
},
|
||||
),
|
||||
},
|
||||
child: Focus(autofocus: true, child: _buildScaffold(l, theme)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildScaffold(AppLocalizations l, ThemeData theme) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
|
|
@ -303,6 +340,14 @@ outputs:
|
|||
}
|
||||
}
|
||||
|
||||
class _SaveIntent extends Intent {
|
||||
const _SaveIntent();
|
||||
}
|
||||
|
||||
class _RunIntent extends Intent {
|
||||
const _RunIntent();
|
||||
}
|
||||
|
||||
class _FlowFile {
|
||||
final String name;
|
||||
final String path;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue