Skip to content

Commit

Permalink
Set accessible-action-default on tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
DataTriny committed Jan 4, 2025
1 parent 396483e commit 359f428
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/gallery/ui/side_bar.slint
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ component SideBarItem inherits Rectangle {
accessible-item-index: root.tab-index;
accessible-item-selectable: true;
accessible-item-selected: root.selected;
accessible-action-default => { self.clicked(); }

states [
pressed when touch.pressed : {
Expand Down
1 change: 1 addition & 0 deletions internal/compiler/widgets/cosmic/tabwidget.slint
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export component TabImpl inherits Rectangle {
accessible-item-index: root.tab-index;
accessible-item-selectable: true;
accessible-item-selected: root.is-current;
accessible-action-default => { touch-area.clicked(); }

Rectangle {
y: 0;
Expand Down
1 change: 1 addition & 0 deletions internal/compiler/widgets/cupertino/tabwidget.slint
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export component TabImpl inherits Rectangle {
accessible-item-index: root.tab-index;
accessible-item-selectable: true;
accessible-item-selected: root.is-current;
accessible-action-default => { i-touch-area.clicked(); }

if (root.is-current || i-touch-area.pressed): Rectangle {
width: 100%;
Expand Down
1 change: 1 addition & 0 deletions internal/compiler/widgets/fluent/tabwidget.slint
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export component TabImpl inherits Rectangle {
accessible-item-index: root.tab-index;
accessible-item-selectable: true;
accessible-item-selected: root.is-current;
accessible-action-default => { i-touch-area.clicked(); }

Rectangle {
clip: true;
Expand Down
1 change: 1 addition & 0 deletions internal/compiler/widgets/material/tabwidget.slint
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export component TabImpl inherits Rectangle {
accessible-item-index: root.tab-index;
accessible-item-selectable: true;
accessible-item-selected: root.active;
accessible-action-default => { i-touch-area.clicked(); }

i-container := Rectangle {
background: MaterialPalette.alternate-background;
Expand Down
3 changes: 3 additions & 0 deletions internal/compiler/widgets/qt/tabwidget.slint
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export component TabImpl inherits NativeTab {
accessible-item-index: root.tab-index;
accessible-item-selectable: true;
accessible-item-selected: root.tab-index == root.current;
accessible-action-default => {
parent.current = root.tab-index;
}
}

export component TabBarImpl inherits TabBarBase {
Expand Down
19 changes: 19 additions & 0 deletions tests/cases/widgets/tabwidget.slint
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,24 @@ assert_eq!(tab2.accessible_item_selected(), Some(false));
assert_eq!(tab3.accessible_item_index(), Some(2));
assert_eq!(tab3.accessible_item_selectable(), Some(true));
assert_eq!(tab3.accessible_item_selected(), Some(false));
// The accessible default action of tabs change the active tab panel
tab2.invoke_accessible_default_action();
assert_eq!(tab2.accessible_item_selectable(), Some(true));
assert_eq!(tab2.accessible_item_selected(), Some(true));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "Second Tab").count(), 2);
assert_eq!(tab1.accessible_item_selectable(), Some(true));
assert_eq!(tab1.accessible_item_selected(), Some(false));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "First Tab").count(), 1);
tab3.invoke_accessible_default_action();
assert_eq!(tab3.accessible_item_selectable(), Some(true));
assert_eq!(tab3.accessible_item_selected(), Some(true));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "Third Tab").count(), 2);
assert_eq!(tab2.accessible_item_selectable(), Some(true));
assert_eq!(tab2.accessible_item_selected(), Some(false));
assert_eq!(slint_testing::ElementHandle::find_by_accessible_label(&instance, "Second Tab").count(), 1);
```
*/

0 comments on commit 359f428

Please sign in to comment.