pub trait TextSelectionControls {
Show 13 methods
// Required methods
fn build_handle(
&self,
app: &mut App,
context: BuildContext,
handle_type: TextSelectionHandleType,
text_line_height: f64,
on_tap: Option<Listener>,
) -> WidgetRef;
fn get_handle_anchor(
&self,
handle_type: TextSelectionHandleType,
text_line_height: f64,
) -> Offset;
fn build_toolbar(
&self,
app: &mut App,
context: BuildContext,
global_editable_region: Rect,
text_line_height: f64,
selection_midpoint: Offset,
endpoints: &[TextSelectionPoint],
delegate: AnyTextSelectionDelegate,
clipboard_status: Option<Ref<ClipboardStatusNotifier>>,
last_secondary_tap_down_position: Option<Offset>,
) -> WidgetRef;
fn get_handle_size(&self, text_line_height: f64) -> Size;
// Provided methods
fn as_text_selection_handle_controls(
&self,
) -> Option<&dyn TextSelectionHandleControls> { ... }
fn can_cut(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool { ... }
fn can_copy(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool { ... }
fn can_paste(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool { ... }
fn can_select_all(
&self,
app: &App,
delegate: AnyTextSelectionDelegate,
) -> bool { ... }
fn handle_cut(&self, app: &mut App, delegate: AnyTextSelectionDelegate) { ... }
fn handle_copy(&self, app: &mut App, delegate: AnyTextSelectionDelegate) { ... }
fn handle_paste(
&self,
app: &mut App,
delegate: AnyTextSelectionDelegate,
) -> Task<()> ⓘ { ... }
fn handle_select_all(
&self,
app: &mut App,
delegate: AnyTextSelectionDelegate,
) { ... }
}Expand description
An interface for building the selection UI, to be provided by the implementer of the toolbar widget.
Parts of this class, including build_toolbar, have been deprecated in favor
of EditableText.contextMenuBuilder, which is now the preferred way to
customize the context menus.
§Use with EditableText.contextMenuBuilder
For backwards compatibility during the deprecation period, when
EditableText.selectionControls is set to an object that does not mix in
TextSelectionHandleControls, EditableText.contextMenuBuilder is ignored
in favor of the deprecated build_toolbar.
To migrate code from build_toolbar to the preferred
EditableText.contextMenuBuilder, while still using build_handle, mix in
TextSelectionHandleControls into the TextSelectionControls subclass when
moving any toolbar code to a callback passed to
EditableText.contextMenuBuilder.
In due course, build_toolbar will be removed, and the mixin will no longer
be necessary as a way to flag to the framework that the code has been
migrated and does not expect build_toolbar to be called.
For more information, see https://docs.flutter.dev/release/breaking-changes/context-menus.
See also:
SelectionArea, which selects appropriate text selection controls based on the current platform.
Required Methods§
Sourcefn build_handle(
&self,
app: &mut App,
context: BuildContext,
handle_type: TextSelectionHandleType,
text_line_height: f64,
on_tap: Option<Listener>,
) -> WidgetRef
fn build_handle( &self, app: &mut App, context: BuildContext, handle_type: TextSelectionHandleType, text_line_height: f64, on_tap: Option<Listener>, ) -> WidgetRef
Builds a selection handle of the given handle_type.
The top left corner of this widget is positioned at the bottom of the selection position.
The supplied on_tap should be invoked when the handle is tapped, if such
interaction is allowed. As a counterexample, the default selection handle
on iOS cupertinoTextSelectionControls does not call on_tap at all,
since its handles are not meant to be tapped.
Sourcefn get_handle_anchor(
&self,
handle_type: TextSelectionHandleType,
text_line_height: f64,
) -> Offset
fn get_handle_anchor( &self, handle_type: TextSelectionHandleType, text_line_height: f64, ) -> Offset
Get the anchor point of the handle relative to itself. The anchor point is the point that is aligned with a specific point in the text. A handle often visually “points to” that location.
Sourcefn build_toolbar(
&self,
app: &mut App,
context: BuildContext,
global_editable_region: Rect,
text_line_height: f64,
selection_midpoint: Offset,
endpoints: &[TextSelectionPoint],
delegate: AnyTextSelectionDelegate,
clipboard_status: Option<Ref<ClipboardStatusNotifier>>,
last_secondary_tap_down_position: Option<Offset>,
) -> WidgetRef
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn build_toolbar( &self, app: &mut App, context: BuildContext, global_editable_region: Rect, text_line_height: f64, selection_midpoint: Offset, endpoints: &[TextSelectionPoint], delegate: AnyTextSelectionDelegate, clipboard_status: Option<Ref<ClipboardStatusNotifier>>, last_secondary_tap_down_position: Option<Offset>, ) -> WidgetRef
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Builds a toolbar near a text selection.
Typically displays buttons for copying and pasting text.
The global_editable_region parameter is the TextField size of the global
coordinate system in logical pixels.
The text_line_height parameter is the RenderEditable.preferredLineHeight
of the RenderEditable we are building a toolbar for.
The selection_midpoint parameter is a general calculation midpoint
parameter of the toolbar. More detailed position information
is computable from the endpoints parameter.
Sourcefn get_handle_size(&self, text_line_height: f64) -> Size
fn get_handle_size(&self, text_line_height: f64) -> Size
Returns the size of the selection handle.
Provided Methods§
Sourcefn as_text_selection_handle_controls(
&self,
) -> Option<&dyn TextSelectionHandleControls>
fn as_text_selection_handle_controls( &self, ) -> Option<&dyn TextSelectionHandleControls>
These controls as TextSelectionHandleControls when they mix it in: Dart’s
selectionControls is TextSelectionHandleControls.
Every type that implements TextSelectionHandleControls answers Some(self); the
framework reads this to leave the toolbar to EditableText.contextMenuBuilder.
Sourcefn can_cut(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn can_cut(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Whether the current selection of the text field managed by the given
delegate can be removed from the text field and placed into the
Clipboard.
By default, false is returned when nothing is selected in the text field.
Subclasses can use this to decide if they should expose the cut functionality to the user.
Sourcefn can_copy(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn can_copy(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Whether the current selection of the text field managed by the given
delegate can be copied to the Clipboard.
By default, false is returned when nothing is selected in the text field.
Subclasses can use this to decide if they should expose the copy functionality to the user.
Sourcefn can_paste(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn can_paste(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Whether the text field managed by the given delegate supports pasting
from the clipboard.
Subclasses can use this to decide if they should expose the paste functionality to the user.
This does not consider the contents of the clipboard. Subclasses may want to, for example, disallow pasting when the clipboard contains an empty string.
Sourcefn can_select_all(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn can_select_all(&self, app: &App, delegate: AnyTextSelectionDelegate) -> bool
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Whether the current selection of the text field managed by the given
delegate can be extended to include the entire content of the text
field.
Subclasses can use this to decide if they should expose the select all functionality to the user.
Sourcefn handle_cut(&self, app: &mut App, delegate: AnyTextSelectionDelegate)
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn handle_cut(&self, app: &mut App, delegate: AnyTextSelectionDelegate)
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Call AnyTextSelectionDelegate::cut_selection to cut current selection.
This is called by subclasses when their cut affordance is activated by the user.
Sourcefn handle_copy(&self, app: &mut App, delegate: AnyTextSelectionDelegate)
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn handle_copy(&self, app: &mut App, delegate: AnyTextSelectionDelegate)
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Call AnyTextSelectionDelegate::copy_selection to copy current selection.
This is called by subclasses when their copy affordance is activated by the user.
Sourcefn handle_paste(
&self,
app: &mut App,
delegate: AnyTextSelectionDelegate,
) -> Task<()> ⓘ
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn handle_paste( &self, app: &mut App, delegate: AnyTextSelectionDelegate, ) -> Task<()> ⓘ
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Call AnyTextSelectionDelegate::paste_text to paste text.
This is called by subclasses when their paste affordance is activated by the user.
Sourcefn handle_select_all(&self, app: &mut App, delegate: AnyTextSelectionDelegate)
👎Deprecated: Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
fn handle_select_all(&self, app: &mut App, delegate: AnyTextSelectionDelegate)
Use contextMenuBuilder instead. This feature was deprecated after v3.3.0-0.5.pre.
Call AnyTextSelectionDelegate::select_all to set the current selection to
contain the entire text value.
Does not hide the toolbar.
This is called by subclasses when their select-all affordance is activated by the user.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".