pub trait StatefulInteractiveElement: InteractiveElement {
Show 44 methods
// Provided methods
fn role(self, role: Role) -> Self { ... }
fn accessibility_id(self, id: impl Into<SharedString>) -> Self { ... }
fn aria_label(self, label: impl Into<SharedString>) -> Self { ... }
fn aria_description(self, description: impl Into<SharedString>) -> Self { ... }
fn aria_value(self, value: impl Into<SharedString>) -> Self { ... }
fn aria_placeholder(self, placeholder: impl Into<SharedString>) -> Self { ... }
fn aria_disabled(self, disabled: bool) -> Self { ... }
fn aria_required(self, required: bool) -> Self { ... }
fn aria_invalid(self, invalid: Invalid) -> Self { ... }
fn aria_modal(self, modal: bool) -> Self { ... }
fn aria_keyshortcuts(self, keyshortcuts: impl Into<SharedString>) -> Self { ... }
fn aria_selected(self, selected: bool) -> Self { ... }
fn aria_expanded(self, expanded: bool) -> Self { ... }
fn aria_toggled(self, toggled: Toggled) -> Self { ... }
fn aria_numeric_value(self, value: f64) -> Self { ... }
fn aria_min_numeric_value(self, value: f64) -> Self { ... }
fn aria_max_numeric_value(self, value: f64) -> Self { ... }
fn aria_orientation(self, orientation: Orientation) -> Self { ... }
fn aria_level(self, level: usize) -> Self { ... }
fn aria_position_in_set(self, position: usize) -> Self { ... }
fn aria_size_of_set(self, size: usize) -> Self { ... }
fn aria_row_index(self, index: usize) -> Self { ... }
fn aria_column_index(self, index: usize) -> Self { ... }
fn aria_row_count(self, count: usize) -> Self { ... }
fn aria_column_count(self, count: usize) -> Self { ... }
fn on_a11y_action(
self,
action: Action,
listener: impl FnMut(Option<&ActionData>, &mut Window, &mut App) + 'static,
) -> Self { ... }
fn focusable(self) -> Self { ... }
fn overflow_scroll(self) -> Self { ... }
fn overflow_x_scroll(self) -> Self { ... }
fn overflow_y_scroll(self) -> Self { ... }
fn restrict_scroll_to_axis(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 hover_listener_mode(self, mode: HoverListenerMode) -> 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 { ... }
fn tooltip_show_delay(self, delay: Duration) -> Self
where Self: Sized { ... }
fn on_resize(
self,
listener: impl Fn(&ResizeEvent, &mut Window, &mut App) + '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 accessibility_id(self, id: impl Into<SharedString>) -> Self
fn accessibility_id(self, id: impl Into<SharedString>) -> Self
Set the author-provided identifier exposed to accessibility clients.
Unlike the GPUI element ID, this value is visible outside the process. Keep it stable and unique within its accessibility tree.
Sourcefn aria_label(self, label: impl Into<SharedString>) -> Self
fn aria_label(self, label: impl Into<SharedString>) -> Self
Set the accessible label for this element.
Sourcefn aria_description(self, description: impl Into<SharedString>) -> Self
fn aria_description(self, description: impl Into<SharedString>) -> Self
Set supplementary information announced after this element’s label, role, and value.
Sourcefn aria_value(self, value: impl Into<SharedString>) -> Self
fn aria_value(self, value: impl Into<SharedString>) -> Self
Set the current textual value for this element.
Sourcefn aria_placeholder(self, placeholder: impl Into<SharedString>) -> Self
fn aria_placeholder(self, placeholder: impl Into<SharedString>) -> Self
Set the placeholder announced when this element has no value.
Sourcefn aria_disabled(self, disabled: bool) -> Self
fn aria_disabled(self, disabled: bool) -> Self
Report whether this control is disabled.
Sourcefn aria_required(self, required: bool) -> Self
fn aria_required(self, required: bool) -> Self
Report whether this form control requires a value.
Sourcefn aria_invalid(self, invalid: Invalid) -> Self
fn aria_invalid(self, invalid: Invalid) -> Self
Report why this form control’s value is invalid.
Sourcefn aria_modal(self, modal: bool) -> Self
fn aria_modal(self, modal: bool) -> Self
Report whether this dialog is modal.
Sourcefn aria_keyshortcuts(self, keyshortcuts: impl Into<SharedString>) -> Self
fn aria_keyshortcuts(self, keyshortcuts: impl Into<SharedString>) -> Self
Report the keyboard shortcut that activates this element to assistive technology.
This is metadata only and does not register a key binding.
Sourcefn aria_selected(self, selected: bool) -> Self
fn aria_selected(self, selected: bool) -> Self
Set the selected state for this element.
Sourcefn aria_expanded(self, expanded: bool) -> Self
fn aria_expanded(self, expanded: bool) -> Self
Set the expanded state for this element.
Sourcefn aria_toggled(self, toggled: Toggled) -> Self
fn aria_toggled(self, toggled: Toggled) -> Self
Set the toggled state for this element.
Sourcefn aria_numeric_value(self, value: f64) -> Self
fn aria_numeric_value(self, value: f64) -> Self
Set the numeric value for this element.
Sourcefn aria_min_numeric_value(self, value: f64) -> Self
fn aria_min_numeric_value(self, value: f64) -> Self
Set the minimum numeric value for this element.
Sourcefn aria_max_numeric_value(self, value: f64) -> Self
fn aria_max_numeric_value(self, value: f64) -> Self
Set the maximum numeric value for this element.
Sourcefn aria_orientation(self, orientation: Orientation) -> Self
fn aria_orientation(self, orientation: Orientation) -> Self
Set the orientation of this element.
Sourcefn aria_level(self, level: usize) -> Self
fn aria_level(self, level: usize) -> Self
Set the heading level of this element.
Sourcefn aria_position_in_set(self, position: usize) -> Self
fn aria_position_in_set(self, position: usize) -> Self
Set the position in set of this element.
Sourcefn aria_size_of_set(self, size: usize) -> Self
fn aria_size_of_set(self, size: usize) -> Self
Set the size of set for this element.
Sourcefn aria_row_index(self, index: usize) -> Self
fn aria_row_index(self, index: usize) -> Self
Set the row index for this element.
Sourcefn aria_column_index(self, index: usize) -> Self
fn aria_column_index(self, index: usize) -> Self
Set the column index for this element.
Sourcefn aria_row_count(self, count: usize) -> Self
fn aria_row_count(self, count: usize) -> Self
Set the row count for this element.
Sourcefn aria_column_count(self, count: usize) -> Self
fn aria_column_count(self, count: usize) -> Self
Set the column count for this element.
Sourcefn on_a11y_action(
self,
action: Action,
listener: impl FnMut(Option<&ActionData>, &mut Window, &mut App) + 'static,
) -> Self
fn on_a11y_action( self, action: Action, listener: impl FnMut(Option<&ActionData>, &mut Window, &mut App) + 'static, ) -> Self
Register a handler for an accessibility action on this element.
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 restrict_scroll_to_axis(self) -> Self
fn restrict_scroll_to_axis(self) -> Self
Restrict scrolling of this element to the axis of the input gesture.
See Style::restrict_scroll_to_axis for details.
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. Transitions caused by layout changes under a stationary mouse also invoke the callback.
By default, keyboard input suppresses hover until the next mouse move, mouse down, or touch. Set
HoverListenerMode::InputModalityIndependent with Self::hover_listener_mode to
continue hit-testing hover after keyboard input.
The fluent API equivalent to Interactivity::on_hover
See Context::listener to get access to a view’s state from this callback.
Sourcefn hover_listener_mode(self, mode: HoverListenerMode) -> Selfwhere
Self: Sized,
fn hover_listener_mode(self, mode: HoverListenerMode) -> Selfwhere
Self: Sized,
Sets how Self::on_hover responds to key presses while the mouse is stationary.
This affects only the hover listener, not hover styles or tooltips. The fluent API
equivalent to Interactivity::hover_listener_mode.
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
Sourcefn tooltip_show_delay(self, delay: Duration) -> Selfwhere
Self: Sized,
fn tooltip_show_delay(self, delay: Duration) -> Selfwhere
Self: Sized,
Set the delay before this element’s tooltip is shown.
The fluent API equivalent to Interactivity::tooltip_show_delay
Sourcefn on_resize(
self,
listener: impl Fn(&ResizeEvent, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
fn on_resize(
self,
listener: impl Fn(&ResizeEvent, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
Bind the given callback to be called when this element’s bounds change size.
The fluent API equivalent to Interactivity::on_resize
See Context::listener to get access to a view’s state from this callback.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".