diff --git a/api/cpp/include/slint-testing.h b/api/cpp/include/slint-testing.h index 4711e7342..a923fbc1d 100644 --- a/api/cpp/include/slint-testing.h +++ b/api/cpp/include/slint-testing.h @@ -316,6 +316,32 @@ public: return std::nullopt; } + /// Returns the accessible-selected of that element, if any. + std::optional 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 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. /// /// Setting the value will invoke the `accessible-action-set-value` callback. diff --git a/internal/backends/testing/search_api.rs b/internal/backends/testing/search_api.rs index e04e40c39..e4d251ad3 100644 --- a/internal/backends/testing/search_api.rs +++ b/internal/backends/testing/search_api.rs @@ -588,6 +588,28 @@ impl ElementHandle { .and_then(|item| item.parse().ok()) } + /// Returns the value of the `accessible-selected` property, if present + pub fn accessible_selected(&self) -> Option { + 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 { + 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 /// `height` properties in Slint code. Returns a zero size if the element is not valid. pub fn size(&self) -> i_slint_core::api::LogicalSize { diff --git a/internal/compiler/typeregister.rs b/internal/compiler/typeregister.rs index 86e153294..57b8491a1 100644 --- a/internal/compiler/typeregister.rs +++ b/internal/compiler/typeregister.rs @@ -120,6 +120,8 @@ pub fn reserved_accessibility_properties() -> impl Iterator