Unverified Commit c9215e6b authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Wiring for semantic actions copy, cut, paste (#14295)

* Roll engine to 6921873c71e700235c0f68f0359be2332f93c8bc
parent 4c21bf10
7c34dfafc9acece1a9438f206bfbb0a9bedba3bf
6921873c71e700235c0f68f0359be2332f93c8bc
......@@ -859,6 +859,15 @@ class RenderCustomPaint extends RenderProxyBox {
if (properties.onDecrease != null) {
config.onDecrease = properties.onDecrease;
}
if (properties.onCopy != null) {
config.onCopy = properties.onCopy;
}
if (properties.onCut != null) {
config.onCut = properties.onCut;
}
if (properties.onPaste != null) {
config.onPaste = properties.onPaste;
}
if (properties.onMoveCursorForwardByCharacter != null) {
config.onMoveCursorForwardByCharacter = properties.onMoveCursorForwardByCharacter;
}
......
......@@ -3015,6 +3015,9 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
VoidCallback onScrollDown,
VoidCallback onIncrease,
VoidCallback onDecrease,
VoidCallback onCopy,
VoidCallback onCut,
VoidCallback onPaste,
MoveCursorHandler onMoveCursorForwardByCharacter,
MoveCursorHandler onMoveCursorBackwardByCharacter,
SetSelectionHandler onSetSelection,
......@@ -3039,6 +3042,9 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
_onScrollDown = onScrollDown,
_onIncrease = onIncrease,
_onDecrease = onDecrease,
_onCopy = onCopy,
_onCut = onCut,
_onPaste = onPaste,
_onMoveCursorForwardByCharacter = onMoveCursorForwardByCharacter,
_onMoveCursorBackwardByCharacter = onMoveCursorBackwardByCharacter,
_onSetSelection = onSetSelection,
......@@ -3365,6 +3371,58 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
markNeedsSemanticsUpdate();
}
/// The handler for [SemanticsAction.copy].
///
/// This is a request to copy the current selection to the clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
VoidCallback get onCopy => _onCopy;
VoidCallback _onCopy;
set onCopy(VoidCallback handler) {
if (_onCopy == handler)
return;
final bool hadValue = _onCopy != null;
_onCopy = handler;
if ((handler != null) != hadValue)
markNeedsSemanticsUpdate();
}
/// The handler for [SemanticsAction.cut].
///
/// This is a request to cut the current selection and place it in the
/// clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
VoidCallback get onCut => _onCut;
VoidCallback _onCut;
set onCut(VoidCallback handler) {
if (_onCut == handler)
return;
final bool hadValue = _onCut != null;
_onCut = handler;
if ((handler != null) != hadValue)
markNeedsSemanticsUpdate();
}
/// The handler for [SemanticsAction.paste].
///
/// This is a request to paste the current content of the clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
VoidCallback get onPaste => _onPaste;
VoidCallback _onPaste;
set onPaste(VoidCallback handler) {
if (_onPaste == handler)
return;
final bool hadValue = _onPaste != null;
_onPaste = handler;
if ((handler != null) != hadValue)
markNeedsSemanticsUpdate();
}
/// The handler for [SemanticsAction.onMoveCursorForwardByCharacter].
///
/// This handler is invoked when the user wants to move the cursor in a
......@@ -3464,6 +3522,12 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
config.onIncrease = _performIncrease;
if (onDecrease != null)
config.onDecrease = _performDecrease;
if (onCopy != null)
config.onCopy = _performCopy;
if (onCut != null)
config.onCut = _performCut;
if (onPaste != null)
config.onPaste = _performPaste;
if (onMoveCursorForwardByCharacter != null)
config.onMoveCursorForwardByCharacter = _performMoveCursorForwardByCharacter;
if (onMoveCursorBackwardByCharacter != null)
......@@ -3512,6 +3576,21 @@ class RenderSemanticsAnnotations extends RenderProxyBox {
onDecrease();
}
void _performCopy() {
if (onCopy != null)
onCopy();
}
void _performCut() {
if (onCut != null)
onCut();
}
void _performPaste() {
if (onPaste != null)
onPaste();
}
void _performMoveCursorForwardByCharacter(bool extendSelection) {
if (onMoveCursorForwardByCharacter != null)
onMoveCursorForwardByCharacter(extendSelection);
......
......@@ -277,6 +277,9 @@ class SemanticsProperties extends DiagnosticableTree {
this.onScrollDown,
this.onIncrease,
this.onDecrease,
this.onCopy,
this.onCut,
this.onPaste,
this.onMoveCursorForwardByCharacter,
this.onMoveCursorBackwardByCharacter,
this.onSetSelection,
......@@ -472,6 +475,31 @@ class SemanticsProperties extends DiagnosticableTree {
/// volume down button.
final VoidCallback onDecrease;
/// The handler for [SemanticsAction.copy].
///
/// This is a request to copy the current selection to the clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
final VoidCallback onCopy;
/// The handler for [SemanticsAction.cut].
///
/// This is a request to cut the current selection and place it in the
/// clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
final VoidCallback onCut;
/// The handler for [SemanticsAction.paste].
///
/// This is a request to paste the current content of the clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
final VoidCallback onPaste;
/// The handler for [SemanticsAction.onMoveCursorForwardByCharacter].
///
/// This handler is invoked when the user wants to move the cursor in a
......@@ -1618,6 +1646,46 @@ class SemanticsConfiguration {
_onDecrease = value;
}
/// The handler for [SemanticsAction.copy].
///
/// This is a request to copy the current selection to the clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
VoidCallback get onCopy => _onCopy;
VoidCallback _onCopy;
set onCopy(VoidCallback value) {
_addArgumentlessAction(SemanticsAction.copy, value);
_onCopy = value;
}
/// The handler for [SemanticsAction.cut].
///
/// This is a request to cut the current selection and place it in the
/// clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
VoidCallback get onCut => _onCut;
VoidCallback _onCut;
set onCut(VoidCallback value) {
_addArgumentlessAction(SemanticsAction.cut, value);
_onCut = value;
}
/// The handler for [SemanticsAction.paste].
///
/// This is a request to paste the current content of the clipboard.
///
/// TalkBack users on Android can trigger this action from the local context
/// menu of a text field, for example.
VoidCallback get onPaste => _onPaste;
VoidCallback _onPaste;
set onPaste(VoidCallback value) {
_addArgumentlessAction(SemanticsAction.paste, value);
_onPaste = value;
}
/// The handler for [SemanticsAction.showOnScreen].
///
/// A request to fully show the semantics node on screen. For example, this
......
......@@ -4852,6 +4852,9 @@ class Semantics extends SingleChildRenderObjectWidget {
VoidCallback onScrollDown,
VoidCallback onIncrease,
VoidCallback onDecrease,
VoidCallback onCopy,
VoidCallback onCut,
VoidCallback onPaste,
MoveCursorHandler onMoveCursorForwardByCharacter,
MoveCursorHandler onMoveCursorBackwardByCharacter,
SetSelectionHandler onSetSelection,
......@@ -4879,6 +4882,9 @@ class Semantics extends SingleChildRenderObjectWidget {
onScrollDown: onScrollDown,
onIncrease: onIncrease,
onDecrease: onDecrease,
onCopy: onCopy,
onCut: onCut,
onPaste: onPaste,
onMoveCursorForwardByCharacter: onMoveCursorForwardByCharacter,
onMoveCursorBackwardByCharacter: onMoveCursorBackwardByCharacter,
onSetSelection: onSetSelection,
......@@ -4948,6 +4954,9 @@ class Semantics extends SingleChildRenderObjectWidget {
onScrollDown: properties.onScrollDown,
onIncrease: properties.onIncrease,
onDecrease: properties.onDecrease,
onCopy: properties.onCopy,
onCut: properties.onCut,
onPaste: properties.onPaste,
onMoveCursorForwardByCharacter: properties.onMoveCursorForwardByCharacter,
onMoveCursorBackwardByCharacter: properties.onMoveCursorBackwardByCharacter,
onSetSelection: properties.onSetSelection,
......@@ -4988,6 +4997,9 @@ class Semantics extends SingleChildRenderObjectWidget {
..onScrollDown = properties.onScrollDown
..onIncrease = properties.onIncrease
..onDecrease = properties.onDecrease
..onCopy = properties.onCopy
..onCut = properties.onCut
..onPaste = properties.onPaste
..onMoveCursorForwardByCharacter = properties.onMoveCursorForwardByCharacter
..onMoveCursorBackwardByCharacter = properties.onMoveCursorForwardByCharacter
..onSetSelection = properties.onSetSelection;
......
......@@ -392,6 +392,9 @@ void main() {
onScrollDown: () => performedActions.add(SemanticsAction.scrollDown),
onIncrease: () => performedActions.add(SemanticsAction.increase),
onDecrease: () => performedActions.add(SemanticsAction.decrease),
onCopy: () => performedActions.add(SemanticsAction.copy),
onCut: () => performedActions.add(SemanticsAction.cut),
onPaste: () => performedActions.add(SemanticsAction.paste),
onMoveCursorForwardByCharacter: (bool _) => performedActions.add(SemanticsAction.moveCursorForwardByCharacter),
onMoveCursorBackwardByCharacter: (bool _) => performedActions.add(SemanticsAction.moveCursorBackwardByCharacter),
onSetSelection: (TextSelection _) => performedActions.add(SemanticsAction.setSelection),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment