use super::{InputElement, KeyboardNavigationMode};
use crate::{ferro_property, AttachedProperty, FerroProperty, Ref, StyledElement};
pub struct KeyboardNavigation;
crate::ferro_static_type!(KeyboardNavigation);
crate::ferro_properties! { impl KeyboardNavigation {
ferro_property!(
pub fn tab_index_property() -> AttachedProperty<i32> {
FerroProperty::register_attached::<KeyboardNavigation, StyledElement, _>("TabIndex", i32::MAX)
}
);
ferro_property!(
pub fn tab_navigation_property() -> AttachedProperty<KeyboardNavigationMode> {
FerroProperty::register_attached::<KeyboardNavigation, InputElement, _>(
"TabNavigation",
KeyboardNavigationMode::Continue,
)
}
);
ferro_property!(
pub fn tab_once_active_element_property() -> AttachedProperty<Option<Ref<InputElement>>> {
FerroProperty::register_attached::<KeyboardNavigation, InputElement, _>("TabOnceActiveElement", None)
}
);
ferro_property!(
pub fn is_tab_stop_property() -> AttachedProperty<bool> {
FerroProperty::register_attached::<KeyboardNavigation, InputElement, _>("IsTabStop", true)
}
);
} }
impl KeyboardNavigation {
pub fn get_tab_index(element: &InputElement) -> i32 {
element.get_value(Self::tab_index_property())
}
pub fn set_tab_index(element: &InputElement, value: i32) {
element.set_value(Self::tab_index_property(), value)
}
pub fn get_tab_navigation(element: &InputElement) -> KeyboardNavigationMode {
element.get_value(Self::tab_navigation_property())
}
pub fn set_tab_navigation(element: &InputElement, value: KeyboardNavigationMode) {
element.set_value(Self::tab_navigation_property(), value)
}
pub fn get_tab_once_active_element(element: &InputElement) -> Option<Ref<InputElement>> {
element.get_value(Self::tab_once_active_element_property())
}
pub fn set_tab_once_active_element(element: &InputElement, value: Option<Ref<InputElement>>) {
element.set_value(Self::tab_once_active_element_property(), value)
}
pub fn set_is_tab_stop(element: &InputElement, value: bool) {
element.set_value(Self::is_tab_stop_property(), value)
}
pub fn get_is_tab_stop(element: &InputElement) -> bool {
element.get_value(Self::is_tab_stop_property())
}
}