contextMenuButtonItems property
Returns the ContextMenuButtonItems representing the buttons in this platform's default selection menu.
See also:
- SelectableRegion.getSelectableButtonItems, which performs a similar role, but for any selectable text, not just specifically SelectableRegion.
- EditableTextState.contextMenuButtonItems, which performs a similar role but for content that is not just selectable but also editable.
- contextMenuAnchors, which provides the anchor points for the default context menu.
- AdaptiveTextSelectionToolbar, which builds the toolbar itself, and can take a list of ContextMenuButtonItems with AdaptiveTextSelectionToolbar.buttonItems.
- AdaptiveTextSelectionToolbar.getAdaptiveButtons, which builds the button Widgets for the current platform given ContextMenuButtonItems.
Implementation
List<ContextMenuButtonItem> get contextMenuButtonItems {
return SelectableRegion.getSelectableButtonItems(
selectionGeometry: _selectionDelegate.value,
onCopy: () {
_copy();
// On Android copy should clear the selection.
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
clearSelection();
case TargetPlatform.iOS:
hideToolbar(false);
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
hideToolbar();
}
},
onSelectAll: () {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.iOS:
case TargetPlatform.fuchsia:
selectAll(SelectionChangedCause.toolbar);
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
selectAll();
hideToolbar();
}
},
onShare: () {
_share();
// On Android, share should clear the selection.
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
clearSelection();
case TargetPlatform.iOS:
hideToolbar(false);
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
hideToolbar();
}
},
)..addAll(_textProcessingActionButtonItems);
}