`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
pull/1687/head
Renzo Olivares 2 years ago committed by GitHub
parent 37af63583f
commit 881a439868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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>
},
),
),
),
);
}
}

Loading…
Cancel
Save