mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
simplistic_editor : Fix keyboard shortcuts on macOS (#1684)
* Define performSelector to receive intents from macOS TextInputPlugin and remove local Shortcuts widget to inherit DefaultTextEditingShortcuts * dart format
This commit is contained in:
@@ -111,7 +111,14 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
|
||||
@override
|
||||
void performSelector(String selectorName) {
|
||||
// Will not implement.
|
||||
final Intent? intent = intentForMacOSSelector(selectorName);
|
||||
|
||||
if (intent != null) {
|
||||
final BuildContext? primaryContext = primaryFocus?.context;
|
||||
if (primaryContext != null) {
|
||||
Actions.invoke(primaryContext, intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -773,28 +780,9 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
}
|
||||
}
|
||||
|
||||
static final Map<ShortcutActivator, Intent> _defaultWebShortcuts =
|
||||
<ShortcutActivator, Intent>{
|
||||
// Activation
|
||||
const SingleActivator(LogicalKeyboardKey.space):
|
||||
const DoNothingAndStopPropagationIntent(),
|
||||
|
||||
// Scrolling
|
||||
const SingleActivator(LogicalKeyboardKey.arrowUp):
|
||||
const DoNothingAndStopPropagationIntent(),
|
||||
const SingleActivator(LogicalKeyboardKey.arrowDown):
|
||||
const DoNothingAndStopPropagationIntent(),
|
||||
const SingleActivator(LogicalKeyboardKey.arrowLeft):
|
||||
const DoNothingAndStopPropagationIntent(),
|
||||
const SingleActivator(LogicalKeyboardKey.arrowRight):
|
||||
const DoNothingAndStopPropagationIntent(),
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Shortcuts(
|
||||
shortcuts: kIsWeb ? _defaultWebShortcuts : <ShortcutActivator, Intent>{},
|
||||
child: Actions(
|
||||
return Actions(
|
||||
actions: _actions,
|
||||
child: Focus(
|
||||
focusNode: widget.focusNode,
|
||||
@@ -824,8 +812,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
textAlign: TextAlign.left,
|
||||
textDirection: _textDirection,
|
||||
locale: Localizations.maybeLocaleOf(context),
|
||||
textHeightBehavior:
|
||||
DefaultTextHeightBehavior.maybeOf(context),
|
||||
textHeightBehavior: DefaultTextHeightBehavior.maybeOf(context),
|
||||
textWidthBasis: TextWidthBasis.parent,
|
||||
obscuringCharacter: '•',
|
||||
obscureText:
|
||||
@@ -850,7 +837,6 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user