ferroui_base/input/
keyboard_navigation.rs1use super::{InputElement, KeyboardNavigationMode};
2use crate::{ferro_property, AttachedProperty, FerroProperty, Ref, StyledElement};
3
4pub struct KeyboardNavigation;
7
8crate::ferro_static_type!(KeyboardNavigation);
9
10crate::ferro_properties! { impl KeyboardNavigation {
11 ferro_property!(
12 pub fn tab_index_property() -> AttachedProperty<i32> {
14 FerroProperty::register_attached::<KeyboardNavigation, StyledElement, _>("TabIndex", i32::MAX)
15 }
16 );
17
18 ferro_property!(
19 pub fn tab_navigation_property() -> AttachedProperty<KeyboardNavigationMode> {
24 FerroProperty::register_attached::<KeyboardNavigation, InputElement, _>(
25 "TabNavigation",
26 KeyboardNavigationMode::Continue,
27 )
28 }
29 );
30
31 ferro_property!(
32 pub fn tab_once_active_element_property() -> AttachedProperty<Option<Ref<InputElement>>> {
38 FerroProperty::register_attached::<KeyboardNavigation, InputElement, _>("TabOnceActiveElement", None)
39 }
40 );
41
42 ferro_property!(
43 pub fn is_tab_stop_property() -> AttachedProperty<bool> {
47 FerroProperty::register_attached::<KeyboardNavigation, InputElement, _>("IsTabStop", true)
48 }
49 );
50} }
51
52impl KeyboardNavigation {
53 pub fn get_tab_index(element: &InputElement) -> i32 {
55 element.get_value(Self::tab_index_property())
56 }
57
58 pub fn set_tab_index(element: &InputElement, value: i32) {
60 element.set_value(Self::tab_index_property(), value)
61 }
62
63 pub fn get_tab_navigation(element: &InputElement) -> KeyboardNavigationMode {
65 element.get_value(Self::tab_navigation_property())
66 }
67
68 pub fn set_tab_navigation(element: &InputElement, value: KeyboardNavigationMode) {
70 element.set_value(Self::tab_navigation_property(), value)
71 }
72
73 pub fn get_tab_once_active_element(element: &InputElement) -> Option<Ref<InputElement>> {
75 element.get_value(Self::tab_once_active_element_property())
76 }
77
78 pub fn set_tab_once_active_element(element: &InputElement, value: Option<Ref<InputElement>>) {
80 element.set_value(Self::tab_once_active_element_property(), value)
81 }
82
83 pub fn set_is_tab_stop(element: &InputElement, value: bool) {
85 element.set_value(Self::is_tab_stop_property(), value)
86 }
87
88 pub fn get_is_tab_stop(element: &InputElement) -> bool {
90 element.get_value(Self::is_tab_stop_property())
91 }
92}