Skip to main content

StatefulInteractiveElement

Trait StatefulInteractiveElement 

Source
pub trait StatefulInteractiveElement: InteractiveElement {
Show 49 methods // Provided methods fn role(self, role: Role) -> Self { ... } fn aria_label(self, label: impl Into<SharedString>) -> Self { ... } fn aria_description(self, description: impl Into<SharedString>) -> Self { ... } fn aria_keyshortcuts(self, keyshortcuts: impl Into<SharedString>) -> Self { ... } fn aria_active_descendant(self) -> Self { ... } fn a11y_synthetic_children( self, f: impl FnOnce(&mut A11ySubtreeBuilder<'_>) + 'static, ) -> Self { ... } fn aria_selected(self, selected: bool) -> Self { ... } fn aria_expanded(self, expanded: bool) -> Self { ... } fn aria_disabled(self, disabled: bool) -> Self { ... } fn aria_read_only(self, read_only: bool) -> Self { ... } fn aria_modal(self, modal: bool) -> Self { ... } fn aria_invalid(self, invalid: bool) -> Self { ... } fn aria_required(self, required: bool) -> Self { ... } fn aria_busy(self, busy: bool) -> Self { ... } fn aria_live(self, politeness: Live) -> Self { ... } fn aria_live_atomic(self, atomic: bool) -> Self { ... } fn aria_toggled(self, toggled: Toggled) -> Self { ... } fn aria_numeric_value(self, value: f64) -> Self { ... } fn aria_numeric_value_step(self, step: f64) -> Self { ... } fn aria_value(self, value: impl Into<SharedString>) -> Self { ... } fn aria_placeholder(self, placeholder: impl Into<SharedString>) -> 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 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_aux_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 external_drag_payload<T>( self, resolver: impl Fn(&T, &mut Window, &mut App) -> Option<ExternalDragPayload> + 'static, ) -> Self where Self: Sized, T: 'static { ... } 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 { ... } fn tooltip_show_delay(self, delay: Duration) -> 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 role(self, role: Role) -> Self

Set the accessible role for this element.

See the accessibility guide for an overview.

Source

fn aria_label(self, label: impl Into<SharedString>) -> Self

Set the accessible label for this element.

Source

fn aria_description(self, description: impl Into<SharedString>) -> Self

Set the accessible description for this element. Unlike the label (which names the element), the description provides supplementary information that assistive technology announces after the name, role, and value - for example a settings subtitle or a hint.

Source

fn aria_keyshortcuts(self, keyshortcuts: impl Into<SharedString>) -> Self

Set the keyboard shortcut(s) that activate this element, announced by assistive technology (maps to AccessKit’s keyboard_shortcut).

Note that this does not create a keymap. It simply instructs assistive technology what the keymap is.

Source

fn aria_active_descendant(self) -> Self

Report this element as the focused node in the accessibility tree, overriding the element that holds real keyboard focus — but only while one of its ancestors actually holds focus.

This implements the aria-activedescendant pattern for composite widgets that keep keyboard focus on a container (e.g. a menu or listbox) while a child is “selected”: set this on the selected child so assistive technology announces and highlights it as focused.

The element must also have a role (and an id) so it produces an accessibility node. Unlike the web’s container-side aria-activedescendant, this is set on the descendant; GPUI honors it only when a focused ancestor is present in the tree, so it is safe to set unconditionally on the selected child — if the container isn’t focused, the claim is ignored.

Source

fn a11y_synthetic_children( self, f: impl FnOnce(&mut A11ySubtreeBuilder<'_>) + 'static, ) -> Self

Contribute synthetic accessibility nodes — nodes that don’t correspond to any element — as children of this element’s a11y node. For example, text runs describing an editor’s text content.

The closure is called after this element is prepainted, and only if it contributed a node to the accessibility tree (i.e. it has an id and a role).

See Element::a11y_synthetic_children for details.

Source

fn aria_selected(self, selected: bool) -> Self

Set the selected state for this element.

Source

fn aria_expanded(self, expanded: bool) -> Self

Set the expanded state for this element.

Source

fn aria_disabled(self, disabled: bool) -> Self

Set whether this element is unavailable for interaction.

Source

fn aria_read_only(self, read_only: bool) -> Self

Set whether this element exposes text that cannot be edited.

Source

fn aria_modal(self, modal: bool) -> Self

Set whether this element is a modal surface.

Source

fn aria_invalid(self, invalid: bool) -> Self

Set whether this element’s value is invalid.

Source

fn aria_required(self, required: bool) -> Self

Set whether this element requires a value.

Source

fn aria_busy(self, busy: bool) -> Self

Set whether this element is currently being updated.

Source

fn aria_live(self, politeness: Live) -> Self

Set how updates to this element should be announced.

Source

fn aria_live_atomic(self, atomic: bool) -> Self

Set whether a live-region update should announce the whole region.

Source

fn aria_toggled(self, toggled: Toggled) -> Self

Set the toggled state for this element.

Source

fn aria_numeric_value(self, value: f64) -> Self

Set the numeric value for this element.

Source

fn aria_numeric_value_step(self, step: f64) -> Self

Set the step by which assistive technology should expect the numeric value of this element to change (e.g. when incrementing a spin button).

Source

fn aria_value(self, value: impl Into<SharedString>) -> Self

Set the string value of this element, e.g. the text content of a simple text input.

Source

fn aria_placeholder(self, placeholder: impl Into<SharedString>) -> Self

Set the placeholder text reported to assistive technology for this element, shown when a text input is empty.

Source

fn aria_min_numeric_value(self, value: f64) -> Self

Set the minimum numeric value for this element.

Source

fn aria_max_numeric_value(self, value: f64) -> Self

Set the maximum numeric value for this element.

Source

fn aria_orientation(self, orientation: Orientation) -> Self

Set the orientation of this element.

Source

fn aria_level(self, level: usize) -> Self

Set the heading level of this element.

Source

fn aria_position_in_set(self, position: usize) -> Self

Set the position in set of this element.

Source

fn aria_size_of_set(self, size: usize) -> Self

Set the size of set for this element.

Source

fn aria_row_index(self, index: usize) -> Self

Set the row index for this element.

Source

fn aria_column_index(self, index: usize) -> Self

Set the column index for this element.

Source

fn aria_row_count(self, count: usize) -> Self

Set the row count for this element.

Source

fn aria_column_count(self, count: usize) -> Self

Set the column count for this element.

Source

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. The handler is called when a screen reader requests the given action.

See the accessibility guide for an overview.

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 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.

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

Bind the given callback to non-primary click events of this element. The fluent API equivalent to Interactivity::on_aux_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 external_drag_payload<T>( self, resolver: impl Fn(&T, &mut Window, &mut App) -> Option<ExternalDragPayload> + 'static, ) -> Self
where Self: Sized, T: 'static,

Registers a callback resolving a payload to offer the platform if a drag started by this element leaves the window. It is invoked at most once per drag gesture, when the pointer exits the viewport. Must be called after Self::on_drag, with the same dragged value type T. The fluent API equivalent to Interactivity::external_drag_payload.

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.

Source

fn tooltip_show_delay(self, delay: Duration) -> Self
where Self: Sized,

Set the delay before this element’s tooltip is shown. The fluent API equivalent to Interactivity::tooltip_show_delay.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§