Skip to main content

TextSelection

Struct TextSelection 

Source
pub struct TextSelection;
Expand description

Window-level operations for text selection.

Implementations§

Source§

impl TextSelection

Source

pub fn selected_text(window: &mut Window, cx: &mut App) -> String

Returns the currently selected text in logical document order.

Source

pub fn has_selection(window: &mut Window, cx: &mut App) -> bool

Returns whether the window has a geometry selection or any participant has an active participant-local selection such as select-all.

Source

pub fn clear(window: &mut Window, cx: &mut App)

Clears window selection and every participant’s local selection.

Source

pub fn clear_for_window(window_id: WindowId, cx: &mut App)

Clears selection for a known window identifier.

Prefer Self::clear when a window reference is available. This narrow entry point supports hosts retiring deprecated window wrappers.

Source

pub fn end(window: &mut Window, cx: &mut App)

Ends the current drag while leaving its selection visible.

Source

pub fn observe_touch_selection( window: &Window, cx: &mut App, callback: impl Fn(&mut App) + 'static, ) -> Subscription

Calls callback whenever the touch selection changes: it appears, its handles move, its menu opens or closes, or it goes away. Whoever draws the handles and the menu re-renders from here.

Source

pub fn touch_selection( window: &Window, cx: &App, ) -> Option<TouchSelectionSnapshot>

Returns the selection a long press made, laid out for its handles and edit menu, or None when the selection was made with a pointer.

Source

pub fn register_touch_ui(bounds: Bounds<Pixels>, window: &Window, cx: &mut App)

Records where a touch handle or the edit menu is painted this frame, so that pressing it does not clear the selection it belongs to. Call from paint, every frame the surface is shown.

Source

pub fn close_edit_menu(window: &mut Window, cx: &mut App)

Closes the edit menu and keeps the selection with its handles.

Source

pub fn select_all(window: &mut Window, cx: &mut App)

Selects all of the text the touch selection started in, keeping the handles and the edit menu over the result.

Source

pub fn begin_edge_drag( edge: SelectionEdge, finger: Point<Pixels>, window: &mut Window, cx: &mut App, )

Starts dragging one end of the touch selection from finger. The other end stays; the menu closes until Self::end_edge_drag.

Source

pub fn update_edge_drag( finger: Point<Pixels>, window: &mut Window, cx: &mut App, )

Moves the dragged end to the text under finger.

Source

pub fn end_edge_drag(window: &mut Window, cx: &mut App)

Ends the handle drag and reopens the edit menu over the result.

Source

pub fn activate_scope( scope: TextSelectionScopeId, window: &mut Window, cx: &mut App, )

Activates the opaque selection scope for this window.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more