mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Add increase/decrease support test (#5224)
This commit is contained in:
parent
7b3e2fcf32
commit
f63523f708
3 changed files with 66 additions and 0 deletions
|
@ -195,6 +195,44 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/// Invokes the increase accessibility action of that element
|
||||
/// (`accessible-action-increment`).
|
||||
void invoke_accessible_increment_action() const
|
||||
{
|
||||
if (auto item = private_api::upgrade_item_weak(inner)) {
|
||||
union IncreaseActionHelper {
|
||||
cbindgen_private::AccessibilityAction action;
|
||||
IncreaseActionHelper()
|
||||
{
|
||||
action.tag = cbindgen_private::AccessibilityAction::Tag::Increment;
|
||||
}
|
||||
~IncreaseActionHelper() { }
|
||||
|
||||
} action;
|
||||
item->item_tree.vtable()->accessibility_action(item->item_tree.borrow(), item->index,
|
||||
&action.action);
|
||||
}
|
||||
}
|
||||
|
||||
/// Invokes the decrease accessibility action of that element
|
||||
/// (`accessible-action-decrement`).
|
||||
void invoke_accessible_decrement_action() const
|
||||
{
|
||||
if (auto item = private_api::upgrade_item_weak(inner)) {
|
||||
union DecreaseActionHelper {
|
||||
cbindgen_private::AccessibilityAction action;
|
||||
DecreaseActionHelper()
|
||||
{
|
||||
action.tag = cbindgen_private::AccessibilityAction::Tag::Decrement;
|
||||
}
|
||||
~DecreaseActionHelper() { }
|
||||
|
||||
} action;
|
||||
item->item_tree.vtable()->accessibility_action(item->item_tree.borrow(), item->index,
|
||||
&action.action);
|
||||
}
|
||||
}
|
||||
|
||||
/// Invokes the default accessibility action of that element
|
||||
/// (`accessible-action-default`).
|
||||
void invoke_accessible_default_action() const
|
||||
|
|
|
@ -174,4 +174,20 @@ impl ElementHandle {
|
|||
})
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Increase value of the element's `accessible-action-increment` property. Note that you can only set this
|
||||
/// property if it is declared in your Slint code.
|
||||
pub fn invoke_accessible_increment_action(&self) {
|
||||
if let Some(item) = self.0.upgrade() {
|
||||
item.accessible_action(&AccessibilityAction::Increment)
|
||||
}
|
||||
}
|
||||
|
||||
/// Decrease value of the element's `accessible-action-decrease` property. Note that you can only set this
|
||||
/// property if it is declared in your Slint code.
|
||||
pub fn invoke_accessible_decrement_action(&self) {
|
||||
if let Some(item) = self.0.upgrade() {
|
||||
item.accessible_action(&AccessibilityAction::Decrement)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,12 @@ assert_eq!(spinbox.accessible_value_maximum(), Some(100f32));
|
|||
assert_eq!(spinbox.accessible_value_minimum(), Some(10f32));
|
||||
assert_eq!(spinbox.accessible_value_step(), Some(0.9));
|
||||
|
||||
spinbox.invoke_accessible_increment_action();
|
||||
assert_eq!(spinbox.accessible_value().unwrap(), "11");
|
||||
|
||||
spinbox.invoke_accessible_decrement_action();
|
||||
assert_eq!(spinbox.accessible_value().unwrap(), "10");
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
@ -54,6 +60,12 @@ assert_eq(spinbox.accessible_value_maximum().value(), 100);
|
|||
assert_eq(spinbox.accessible_value_minimum().value(), 10);
|
||||
assert_eq(spinbox.accessible_value_step().value(), 0.9);
|
||||
|
||||
spinbox.invoke_accessible_increment_action();
|
||||
assert_eq(spinbox.accessible_value().value(), "11");
|
||||
|
||||
spinbox.invoke_accessible_decrement_action();
|
||||
assert_eq(spinbox.accessible_value().value(), "10");
|
||||
|
||||
```
|
||||
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue