mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00
Add ElementHandle::accessible_role() to the C++ API (#5388)
This commit is contained in:
parent
f1987cd208
commit
5247b0afae
2 changed files with 17 additions and 0 deletions
|
@ -11,6 +11,9 @@
|
|||
# ifdef SLINT_FEATURE_EXPERIMENTAL
|
||||
|
||||
namespace slint::testing {
|
||||
|
||||
using slint::cbindgen_private::AccessibleRole;
|
||||
|
||||
/// Init the testing backend.
|
||||
/// Should be called before any other Slint function that can access the platform.
|
||||
/// Then future windows will not appear on the screen anymore
|
||||
|
@ -205,6 +208,18 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the value of the element's `accessible-role` property, if present. Use this property
|
||||
/// to locate elements by their type/role, i.e. buttons, checkboxes, etc.
|
||||
std::optional<slint::testing::AccessibleRole> accessible_role() const
|
||||
{
|
||||
if (inner.element_index != 0)
|
||||
return std::nullopt;
|
||||
if (auto item = private_api::upgrade_item_weak(inner.item)) {
|
||||
return item->item_tree.vtable()->accessible_role(item->item_tree.borrow(), item->index);
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/// Returns the accessible-label of that element, if any.
|
||||
std::optional<SharedString> accessible_label() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue