Skip to main content

ElementExt

Trait ElementExt 

Source
pub trait ElementExt: Sized + ParentElement {
    // Provided methods
    fn text_selection_scope(
        self,
        scope: TextSelectionScopeId,
    ) -> impl IntoElement
       where Self: IntoElement { ... }
    fn keep_text_selection(self, id: impl Into<ElementId>) -> Self { ... }
    fn on_prepaint<F>(self, callback: F) -> Self
       where F: FnOnce(Bounds<Pixels>, &mut Window, &mut App) + 'static { ... }
}
Expand description

Extends a GPUI parent element with post-layout prepaint observation.

Provided Methods§

Source

fn text_selection_scope(self, scope: TextSelectionScopeId) -> impl IntoElement
where Self: IntoElement,

Marks this element subtree as belonging to a text-selection scope.

Source

fn keep_text_selection(self, id: impl Into<ElementId>) -> Self

Keeps the window’s text selection when this element is pressed, for one that acts on the selection, such as a button beside it: pressing anywhere on it neither clears the selection nor starts a new one, so its click still finds the selection. id must be unique among this element’s children. Works inside a cached view.

The window remembers each element marked this way until it closes, so mark the row of buttons, not each row of a long list.

Source

fn on_prepaint<F>(self, callback: F) -> Self
where F: FnOnce(Bounds<Pixels>, &mut Window, &mut App) + 'static,

Invokes callback during prepaint with this element’s resolved bounds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> ElementExt for T
where T: ParentElement,