mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +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
|
@override
|
||||||
void performSelector(String selectorName) {
|
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
|
@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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Shortcuts(
|
return Actions(
|
||||||
shortcuts: kIsWeb ? _defaultWebShortcuts : <ShortcutActivator, Intent>{},
|
|
||||||
child: Actions(
|
|
||||||
actions: _actions,
|
actions: _actions,
|
||||||
child: Focus(
|
child: Focus(
|
||||||
focusNode: widget.focusNode,
|
focusNode: widget.focusNode,
|
||||||
@@ -824,8 +812,7 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
textDirection: _textDirection,
|
textDirection: _textDirection,
|
||||||
locale: Localizations.maybeLocaleOf(context),
|
locale: Localizations.maybeLocaleOf(context),
|
||||||
textHeightBehavior:
|
textHeightBehavior: DefaultTextHeightBehavior.maybeOf(context),
|
||||||
DefaultTextHeightBehavior.maybeOf(context),
|
|
||||||
textWidthBasis: TextWidthBasis.parent,
|
textWidthBasis: TextWidthBasis.parent,
|
||||||
obscuringCharacter: '•',
|
obscuringCharacter: '•',
|
||||||
obscureText:
|
obscureText:
|
||||||
@@ -850,7 +837,6 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user