pub struct TextSelection;Expand description
Window-level operations for text selection.
Implementations§
Source§impl TextSelection
impl TextSelection
Sourcepub fn selected_text(window: &mut Window, cx: &mut App) -> String
pub fn selected_text(window: &mut Window, cx: &mut App) -> String
Returns the currently selected text in logical document order.
Sourcepub fn has_selection(window: &mut Window, cx: &mut App) -> bool
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.
Sourcepub fn clear(window: &mut Window, cx: &mut App)
pub fn clear(window: &mut Window, cx: &mut App)
Clears window selection and every participant’s local selection.
Sourcepub fn clear_for_window(window_id: WindowId, cx: &mut App)
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.
Sourcepub fn end(window: &mut Window, cx: &mut App)
pub fn end(window: &mut Window, cx: &mut App)
Ends the current drag while leaving its selection visible.
Sourcepub fn observe_touch_selection(
window: &Window,
cx: &mut App,
callback: impl Fn(&mut App) + 'static,
) -> Subscription
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.
Sourcepub fn touch_selection(
window: &Window,
cx: &App,
) -> Option<TouchSelectionSnapshot>
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.
Sourcepub fn register_touch_ui(bounds: Bounds<Pixels>, window: &Window, cx: &mut App)
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.
Closes the edit menu and keeps the selection with its handles.
Sourcepub fn select_all(window: &mut Window, cx: &mut App)
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.
Sourcepub fn begin_edge_drag(
edge: SelectionEdge,
finger: Point<Pixels>,
window: &mut Window,
cx: &mut App,
)
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.
Sourcepub fn update_edge_drag(
finger: Point<Pixels>,
window: &mut Window,
cx: &mut App,
)
pub fn update_edge_drag( finger: Point<Pixels>, window: &mut Window, cx: &mut App, )
Moves the dragged end to the text under finger.
Sourcepub fn end_edge_drag(window: &mut Window, cx: &mut App)
pub fn end_edge_drag(window: &mut Window, cx: &mut App)
Ends the handle drag and reopens the edit menu over the result.
Sourcepub fn activate_scope(
scope: TextSelectionScopeId,
window: &mut Window,
cx: &mut App,
)
pub fn activate_scope( scope: TextSelectionScopeId, window: &mut Window, cx: &mut App, )
Activates the opaque selection scope for this window.
Auto Trait Implementations§
impl Freeze for TextSelection
impl RefUnwindSafe for TextSelection
impl Send for TextSelection
impl Sync for TextSelection
impl Unpin for TextSelection
impl UnsafeUnpin for TextSelection
impl UnwindSafe for TextSelection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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