StatefulInteractiveElement

Trait StatefulInteractiveElement 

Source
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§

Source

fn focusable(self) -> Self

Set this element to focusable.

Source

fn overflow_scroll(self) -> Self

Set the overflow x and y to scroll.

Source

fn overflow_x_scroll(self) -> Self

Set the overflow x to scroll.

Source

fn overflow_y_scroll(self) -> Self

Set the overflow y to scroll.

Source

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.

Source

fn track_scroll(self, scroll_handle: &ScrollHandle) -> Self

Track the scroll state of this element with the given handle.

Source

fn anchor_scroll(self, scroll_anchor: Option<ScrollAnchor>) -> Self

Track the scroll state of this element with the given handle.

Source

fn active(self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Self
where Self: Sized,

Set the given styles to be applied when this element is active.

Source

fn group_active( self, group_name: impl Into<SharedString>, f: impl FnOnce(StyleRefinement) -> StyleRefinement, ) -> Self
where Self: Sized,

Set the given styles to be applied when this element’s group is active.

Source

fn on_click( self, listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, ) -> Self
where 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.

Source

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,

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.

Source

fn on_hover( self, listener: impl Fn(&bool, &mut Window, &mut App) + 'static, ) -> Self
where 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.

Source

fn tooltip( self, build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static, ) -> Self
where 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.

Source

fn hoverable_tooltip( self, build_tooltip: impl Fn(&mut Window, &mut App) -> AnyView + 'static, ) -> Self
where 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.

Implementors§