mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
[checkbox] fix accessible-action-default when checkbox is disabled (#10173)
This commit is contained in:
parent
25ec2fb589
commit
80a9f397d9
6 changed files with 32 additions and 9 deletions
|
|
@ -20,7 +20,7 @@ export component CheckBox {
|
|||
accessible-label: root.text;
|
||||
accessible-checked <=> root.checked;
|
||||
accessible-role: checkbox;
|
||||
accessible-action-default => { state-layer.clicked(); }
|
||||
accessible-action-default => { if (root.enabled) {state-layer.clicked();} }
|
||||
forward-focus: state-layer;
|
||||
|
||||
states [
|
||||
|
|
|
|||
|
|
@ -22,8 +22,10 @@ export component CheckBox {
|
|||
accessible-checked <=> root.checked;
|
||||
accessible-role: checkbox;
|
||||
accessible-action-default => {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
if (root.enabled) {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
}
|
||||
}
|
||||
forward-focus: i-focus-scope;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ export component CheckBox {
|
|||
accessible-checked <=> root.checked;
|
||||
accessible-role: checkbox;
|
||||
accessible-action-default => {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
if (root.enabled) {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
}
|
||||
}
|
||||
forward-focus: focus-scope;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@ export component CheckBox {
|
|||
accessible-checked <=> root.checked;
|
||||
accessible-role: checkbox;
|
||||
accessible-action-default => {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
if (root.enabled) {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
}
|
||||
}
|
||||
forward-focus: i-focus-scope;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ export component CheckBox inherits NativeCheckBox {
|
|||
accessible-label <=> root.text;
|
||||
accessible-role: checkbox;
|
||||
accessible-action-default => {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
if (root.enabled) {
|
||||
root.checked = !root.checked;
|
||||
root.toggled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export component TestCase inherits Window {
|
|||
|
||||
in-out property <string> toggled;
|
||||
in-out property <bool> checked <=> a.checked;
|
||||
in-out property <bool> enabled <=> a.enabled;
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: start;
|
||||
|
|
@ -36,10 +37,18 @@ assert_eq!(aaa.accessible_value_minimum(), None);
|
|||
assert_eq!(aaa.accessible_value_step(), None);
|
||||
assert_eq!(aaa.accessible_checked(), Some(false));
|
||||
assert_eq!(aaa.accessible_checkable(), Some(true));
|
||||
assert_eq!(aaa.accessible_enabled(), Some(true));
|
||||
aaa.invoke_accessible_default_action();
|
||||
assert_eq!(instance.get_checked(), true, "CheckBox a was not checked");
|
||||
assert_eq!(aaa.accessible_checked(), Some(true));
|
||||
assert_eq!(instance.get_toggled(), SharedString::from("a"));
|
||||
|
||||
instance.set_enabled(false);
|
||||
assert_eq!(aaa.accessible_enabled(), Some(false));
|
||||
assert_eq!(instance.get_toggled(), SharedString::from("a"));
|
||||
|
||||
aaa.invoke_accessible_default_action();
|
||||
assert_eq!(instance.get_toggled(), SharedString::from("a"));
|
||||
```
|
||||
|
||||
```cpp
|
||||
|
|
@ -60,7 +69,13 @@ aaa.invoke_accessible_default_action();
|
|||
assert_eq(instance.get_checked(), true);
|
||||
assert_eq(aaa.accessible_checked().value(), true);
|
||||
assert_eq(instance.get_toggled(), "a");
|
||||
assert_eq(aaa.accessible_enabled().value(), true);
|
||||
|
||||
instance.set_enabled(false);
|
||||
assert_eq(aaa.accessible_enabled().value(), false);
|
||||
assert_eq(instance.get_toggled(), "a");
|
||||
aaa.invoke_accessible_default_action();
|
||||
assert_eq(instance.get_toggled(), "a");
|
||||
```
|
||||
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue