Changelog: Add accessible-selectable and accessible-selected properties

This commit is contained in:
Arnold Loubriat 2024-10-13 22:33:05 +02:00 committed by Simon Hausmann
parent 66ebcbd1b7
commit 19f09950c2
8 changed files with 60 additions and 0 deletions

View file

@ -316,6 +316,32 @@ public:
return std::nullopt; return std::nullopt;
} }
/// Returns the accessible-selected of that element, if any.
std::optional<bool> accessible_selected() const
{
if (auto result = get_accessible_string_property(
cbindgen_private::AccessibleStringProperty::Selected)) {
if (*result == "true")
return true;
else if (*result == "false")
return false;
}
return std::nullopt;
}
/// Returns the accessible-selectable of that element, if any.
std::optional<bool> accessible_selectable() const
{
if (auto result = get_accessible_string_property(
cbindgen_private::AccessibleStringProperty::Selectable)) {
if (*result == "true")
return true;
else if (*result == "false")
return false;
}
return std::nullopt;
}
/// Sets the accessible-value of that element. /// Sets the accessible-value of that element.
/// ///
/// Setting the value will invoke the `accessible-action-set-value` callback. /// Setting the value will invoke the `accessible-action-set-value` callback.

View file

@ -588,6 +588,28 @@ impl ElementHandle {
.and_then(|item| item.parse().ok()) .and_then(|item| item.parse().ok())
} }
/// Returns the value of the `accessible-selected` property, if present
pub fn accessible_selected(&self) -> Option<bool> {
if self.element_index != 0 {
return None;
}
self.item
.upgrade()
.and_then(|item| item.accessible_string_property(AccessibleStringProperty::Selected))
.and_then(|item| item.parse().ok())
}
/// Returns the value of the `accessible-selectable` property, if present
pub fn accessible_selectable(&self) -> Option<bool> {
if self.element_index != 0 {
return None;
}
self.item
.upgrade()
.and_then(|item| item.accessible_string_property(AccessibleStringProperty::Selectable))
.and_then(|item| item.parse().ok())
}
/// Returns the size of the element in logical pixels. This corresponds to the value of the `width` and /// Returns the size of the element in logical pixels. This corresponds to the value of the `width` and
/// `height` properties in Slint code. Returns a zero size if the element is not valid. /// `height` properties in Slint code. Returns a zero size if the element is not valid.
pub fn size(&self) -> i_slint_core::api::LogicalSize { pub fn size(&self) -> i_slint_core::api::LogicalSize {

View file

@ -120,6 +120,8 @@ pub fn reserved_accessibility_properties() -> impl Iterator<Item = (&'static str
"accessible-action-set-value", "accessible-action-set-value",
Type::Callback { return_type: None, args: vec![Type::String] }, Type::Callback { return_type: None, args: vec![Type::String] },
), ),
("accessible-selectable", Type::Bool),
("accessible-selected", Type::Bool),
] ]
.into_iter() .into_iter()
} }

View file

@ -112,6 +112,8 @@ export component ListItem {
layout := HorizontalLayout { layout := HorizontalLayout {
padding-bottom: 8px; padding-bottom: 8px;
accessible-role: list-item; accessible-role: list-item;
accessible-selectable: true;
accessible-selected: root.is-selected;
StateLayerBase { StateLayerBase {
width: 100%; width: 100%;

View file

@ -74,6 +74,8 @@ export component ListItem {
padding-left: root.padding-horizontal; padding-left: root.padding-horizontal;
padding-right: root.padding-horizontal; padding-right: root.padding-horizontal;
accessible-role: list-item; accessible-role: list-item;
accessible-selectable: true;
accessible-selected: root.is-selected;
i-background := Rectangle { i-background := Rectangle {
background: transparent; background: transparent;

View file

@ -79,6 +79,8 @@ export component ListItem {
padding-right: 16px; padding-right: 16px;
spacing: 4px; spacing: 4px;
accessible-role: list-item; accessible-role: list-item;
accessible-selectable: true;
accessible-selected: root.is-selected;
i-text := Text { i-text := Text {
text: root.item.text; text: root.item.text;

View file

@ -146,6 +146,8 @@ export component ListItem {
padding-left: 12px; padding-left: 12px;
padding-right: 12px; padding-right: 12px;
accessible-role: list-item; accessible-role: list-item;
accessible-selectable: true;
accessible-selected: root.is-selected;
label := Text { label := Text {
text: root.item.text; text: root.item.text;

View file

@ -21,6 +21,8 @@ pub enum AccessibleStringProperty {
Description, Description,
Label, Label,
PlaceholderText, PlaceholderText,
Selectable,
Selected,
Value, Value,
ValueMaximum, ValueMaximum,
ValueMinimum, ValueMinimum,