pub trait StatefulInteractiveElement: InteractiveElement {
Show 40 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_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 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
重导出所有内置元素类型 希望使用需要状态的标准 RGPUI 交互功能的元素的 trait。
Provided Methods§
Sourcefn aria_label(self, label: impl Into<SharedString>) -> Self
fn aria_label(self, label: impl Into<SharedString>) -> Self
设置此元素的无障碍标签。
Sourcefn aria_description(self, description: impl Into<SharedString>) -> Self
fn aria_description(self, description: impl Into<SharedString>) -> Self
设置此元素的无障碍描述。与标签(命名元素)不同,描述提供辅助技术 在名称、角色和值之后公布的补充信息——例如设置子标题或提示。
Sourcefn aria_keyshortcuts(self, keyshortcuts: impl Into<SharedString>) -> Self
fn aria_keyshortcuts(self, keyshortcuts: impl Into<SharedString>) -> Self
设置激活此元素的键盘快捷键,由辅助技术公布
(映射到 AccessKit 的 keyboard_shortcut)。
注意这不会创建按键映射,只是告知辅助技术按键映射是什么。
Sourcefn aria_active_descendant(self) -> Self
fn aria_active_descendant(self) -> Self
将此元素报告为无障碍树中的聚焦节点,覆盖实际持有键盘焦点的元素 ——但仅在其某个祖先实际持有焦点时。
这实现了 aria-activedescendant 模式,用于将键盘焦点保持在容器上
(如菜单或列表框)而子元素被“选中“的复合组件:在选中的子元素上设置
此属性,使辅助技术将其宣布并高亮为聚焦。
元素还必须有 role(和 id),以便生成无障碍节点。
与网页的容器端 aria-activedescendant 不同,这是设置在后代上的;
RGPUI 仅在树中存在聚焦祖先时才将其视为有效,因此可以无条件地设置在
选中的子元素上——如果容器未聚焦,该声明将被忽略。
Sourcefn a11y_synthetic_children(
self,
f: impl FnOnce(&mut A11ySubtreeBuilder<'_>) + 'static,
) -> Self
fn a11y_synthetic_children( self, f: impl FnOnce(&mut A11ySubtreeBuilder<'_>) + 'static, ) -> Self
贡献合成无障碍节点——不对应任何元素的节点——作为此元素无障碍节点的子节点。 例如描述编辑器文本内容的文本运行。
闭包在此元素预绘制后调用,且仅在它向无障碍树贡献了节点(即有 id 和
role)时才调用。
参见 Element::a11y_synthetic_children 了解详情。
Sourcefn aria_selected(self, selected: bool) -> Self
fn aria_selected(self, selected: bool) -> Self
设置此元素的选中状态。
Sourcefn aria_expanded(self, expanded: bool) -> Self
fn aria_expanded(self, expanded: bool) -> Self
设置此元素的展开状态。
Sourcefn aria_toggled(self, toggled: Toggled) -> Self
fn aria_toggled(self, toggled: Toggled) -> Self
设置此元素的切换状态。
Sourcefn aria_numeric_value(self, value: f64) -> Self
fn aria_numeric_value(self, value: f64) -> Self
设置此元素的数值。
Sourcefn aria_numeric_value_step(self, step: f64) -> Self
fn aria_numeric_value_step(self, step: f64) -> Self
设置辅助技术应预期此元素数值变化的步长(例如递增微调按钮时)。
Sourcefn aria_value(self, value: impl Into<SharedString>) -> Self
fn aria_value(self, value: impl Into<SharedString>) -> Self
设置此元素的字符串值,例如简单文本输入框的文本内容。
Sourcefn aria_placeholder(self, placeholder: impl Into<SharedString>) -> Self
fn aria_placeholder(self, placeholder: impl Into<SharedString>) -> Self
设置向辅助技术报告的占位符文本,在文本输入为空时显示。
Sourcefn aria_min_numeric_value(self, value: f64) -> Self
fn aria_min_numeric_value(self, value: f64) -> Self
设置此元素的最小数值。
Sourcefn aria_max_numeric_value(self, value: f64) -> Self
fn aria_max_numeric_value(self, value: f64) -> Self
设置此元素的最大数值。
Sourcefn aria_orientation(self, orientation: Orientation) -> Self
fn aria_orientation(self, orientation: Orientation) -> Self
设置此元素的方向。
Sourcefn aria_level(self, level: usize) -> Self
fn aria_level(self, level: usize) -> Self
设置此元素的标题级别。
Sourcefn aria_position_in_set(self, position: usize) -> Self
fn aria_position_in_set(self, position: usize) -> Self
设置此元素在集合中的位置。
Sourcefn aria_size_of_set(self, size: usize) -> Self
fn aria_size_of_set(self, size: usize) -> Self
设置此元素的集合大小。
Sourcefn aria_row_index(self, index: usize) -> Self
fn aria_row_index(self, index: usize) -> Self
设置此元素的行索引。
Sourcefn aria_column_index(self, index: usize) -> Self
fn aria_column_index(self, index: usize) -> Self
设置此元素的列索引。
Sourcefn aria_row_count(self, count: usize) -> Self
fn aria_row_count(self, count: usize) -> Self
设置此元素的行数。
Sourcefn aria_column_count(self, count: usize) -> Self
fn aria_column_count(self, count: usize) -> Self
设置此元素的列数。
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
为此元素注册无障碍动作的处理器。 当屏幕阅读器请求给定动作时调用处理器。
参见无障碍指南了解概述。
Sourcefn overflow_scroll(self) -> Self
fn overflow_scroll(self) -> Self
将 x 和 y 溢出设置为滚动。
Sourcefn overflow_x_scroll(self) -> Self
fn overflow_x_scroll(self) -> Self
将 x 溢出设置为滚动。
Sourcefn overflow_y_scroll(self) -> Self
fn overflow_y_scroll(self) -> Self
将 y 溢出设置为滚动。
Sourcefn restrict_scroll_to_axis(self) -> Self
fn restrict_scroll_to_axis(self) -> Self
将滚动限制为输入手势的方向轴。
参见 Style::restrict_scroll_to_axis 的说明。
Sourcefn track_scroll(self, scroll_handle: &ScrollHandle) -> Self
fn track_scroll(self, scroll_handle: &ScrollHandle) -> Self
使用给定句柄跟踪此元素的滚动状态。
Sourcefn anchor_scroll(self, scroll_anchor: Option<ScrollAnchor>) -> Self
fn anchor_scroll(self, scroll_anchor: Option<ScrollAnchor>) -> Self
使用给定锚点跟踪此元素的滚动状态。
Sourcefn active(self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Selfwhere
Self: Sized,
fn active(self, f: impl FnOnce(StyleRefinement) -> StyleRefinement) -> Selfwhere
Self: Sized,
设置此元素处于激活状态时应用的给定样式。
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,
设置此元素的分组处于激活状态时应用的给定样式。
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,
将给定回调绑定到此元素的点击事件。
Interactivity::on_click 的流式 API 等价物。
参见 Context::listener 了解如何从此回调访问视图状态。
Sourcefn on_aux_click(
self,
listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
fn on_aux_click(
self,
listener: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
) -> Selfwhere
Self: Sized,
将给定回调绑定到此元素的非主按钮点击事件。
Interactivity::on_aux_click 的流式 API 等价物。
参见 Context::listener 了解如何从此回调访问视图状态。
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
在拖拽启动时,此回调用于创建一个新视图来渲染拖拽值,用于拖放操作。
此 API 也应作为 InteractiveElement::on_drag_move API 的“拖拽开始“等价物使用。
回调还可以访问触发点击相对于父元素原点的偏移量。
Interactivity::on_drag 的流式 API 等价物。
参见 Context::listener 了解如何从此回调访问视图状态。
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,
将给定回调绑定到此元素的悬停开始和结束事件。注意传入回调的布尔值
在悬停开始时为 true,结束时为 false。
鼠标静止时由布局变化引起的过渡也会触发回调。
Interactivity::on_hover 的流式 API 等价物。
参见 Context::listener 了解如何从此回调访问视图状态。
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,
使用给定回调在鼠标悬停于此元素时构建新的工具提示视图。
Interactivity::tooltip 的流式 API 等价物。
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,
使用给定回调在鼠标悬停于此元素时构建新的工具提示视图。
工具提示本身也可悬停,当用户将鼠标移入工具提示时不会消失。
Interactivity::hoverable_tooltip 的流式 API 等价物。
Sourcefn tooltip_show_delay(self, delay: Duration) -> Selfwhere
Self: Sized,
fn tooltip_show_delay(self, delay: Duration) -> Selfwhere
Self: Sized,
设置此元素的工具提示显示前的延迟时间。
Interactivity::tooltip_show_delay 的流式 API 等价物。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".