pub trait StatefulInteractiveElement: InteractiveElement {
Show 14 methods
// Provided methods
fn focusable(self) -> Self { ... }
fn overflow_scroll(self) -> Self { ... }
fn overflow_x_scroll(self) -> Self { ... }
fn overflow_y_scroll(self) -> Self { ... }
fn scrollbar_width(self, width: impl Into<AbsoluteLength>) -> Self { ... }
fn track_scroll(self, scroll_handle: &ScrollHandle) -> Self { ... }
fn anchor_scroll(self, scroll_anchor: Option<ScrollAnchor>) -> Self { ... }
fn active(self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self
where Self: Sized { ... }
fn group_active(
self,
group_name: impl Into<SharedString>,
f: impl FnOnce(StyleRefinement) -> StyleRefinement,
) -> Self
where Self: Sized { ... }
fn on_click(
self,
listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
) -> Self
where Self: Sized { ... }
fn on_drag<T, W>(
self,
value: T,
constructor: impl Fn(&T, Point<Pixels>, &mut Window, &mut App) -> Entity<W> + 'static,
) -> Self
where Self: Sized,
T: 'static,
W: 'static + Render { ... }
fn on_hover(
self,
listener: impl Fn(&bool, &mut Window, &mut App) + 'static,
) -> Self
where Self: Sized { ... }
fn tooltip(
self,
build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Self
where Self: Sized { ... }
fn hoverable_tooltip(
self,
build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Self
where Self: Sized { ... }
}Expand description
A trait for elements that want to use the standard GPUI interactivity features that require state.
Provided Methods§
Sourcefn overflow_scroll(self) -> Self
fn overflow_scroll(self) -> Self
Set the overflow x and y to scroll.
Sourcefn overflow_x_scroll(self) -> Self
fn overflow_x_scroll(self) -> Self
Set the overflow x to scroll.
Sourcefn overflow_y_scroll(self) -> Self
fn overflow_y_scroll(self) -> Self
Set the overflow y to scroll.
Sourcefn scrollbar_width(self, width: impl Into<AbsoluteLength>) -> Self
fn scrollbar_width(self, width: impl Into<AbsoluteLength>) -> Self
Set the space to be reserved for rendering the scrollbar.
This will only affect the layout of the element when overflow for this element is set to
Overflow::Scroll.
Sourcefn track_scroll(self, scroll_handle: &ScrollHandle) -> Self
fn track_scroll(self, scroll_handle: &ScrollHandle) -> Self
Track the scroll state of this element with the given handle.
Sourcefn anchor_scroll(self, scroll_anchor: Option<ScrollAnchor>) -> Self
fn anchor_scroll(self, scroll_anchor: Option<ScrollAnchor>) -> Self
Track the scroll state of this element with the given handle.
Sourcefn active(self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Selfwhere
Self: Sized,
fn active(self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Selfwhere
Self: Sized,
Set the given styles to be applied when this element is active.
Sourcefn group_active(
self,
group_name: impl Into<SharedString>,
f: impl FnOnce(StyleRefinement) -> StyleRefinement,
) -> Selfwhere
Self: Sized,
fn group_active(
self,
group_name: impl Into<SharedString>,
f: impl FnOnce(StyleRefinement) -> StyleRefinement,
) -> Selfwhere
Self: Sized,
Set the given styles to be applied when this element’s group is active.
Sourcefn on_click(
self,
listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
fn on_click(
self,
listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
Bind the given callback to click events of this element.
The fluent API equivalent to Interactivity::on_click.
See Context::listener to get access to a view’s state from this callback.
Sourcefn on_drag<T, W>(
self,
value: T,
constructor: impl Fn(&T, Point<Pixels>, &mut Window, &mut App) -> Entity<W> + 'static,
) -> Self
fn on_drag<T, W>( self, value: T, constructor: impl Fn(&T, Point<Pixels>, &mut Window, &mut App) -> Entity<W> + 'static, ) -> Self
On drag initiation, this callback will be used to create a new view to render the dragged value for a
drag and drop operation. This API should also be used as the equivalent of ‘on drag start’ with
the InteractiveElement::on_drag_move API.
The callback also has access to the offset of triggering click from the origin of parent element.
The fluent API equivalent to Interactivity::on_drag.
See Context::listener to get access to a view’s state from this callback.
Sourcefn on_hover(
self,
listener: impl Fn(&bool, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
fn on_hover(
self,
listener: impl Fn(&bool, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
Bind the given callback on the hover start and end events of this element. Note that the boolean
passed to the callback is true when the hover starts and false when it ends.
The fluent API equivalent to Interactivity::on_hover.
See Context::listener to get access to a view’s state from this callback.
Sourcefn tooltip(
self,
build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Selfwhere
Self: Sized,
fn tooltip(
self,
build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Selfwhere
Self: Sized,
Use the given callback to construct a new tooltip view when the mouse hovers over this element.
The fluent API equivalent to Interactivity::tooltip.
Sourcefn hoverable_tooltip(
self,
build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Selfwhere
Self: Sized,
fn hoverable_tooltip(
self,
build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static,
) -> Selfwhere
Self: Sized,
Use the given callback to construct a new tooltip view when the mouse hovers over this element.
The tooltip itself is also hoverable and won’t disappear when the user moves the mouse into
the tooltip. The fluent API equivalent to Interactivity::hoverable_tooltip.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.