Skip to content

Commit

Permalink
13679: Focus and accessibility improvements of Spin edit controls
Browse files Browse the repository at this point in the history
  • Loading branch information
krasko78 committed Feb 23, 2025
1 parent 9033dc2 commit 8dcfb2b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/framework/accessibility/iaccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class IAccessible
List,
ListItem,
MenuItem,
SpinBox,
Range,
Group,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ QAccessible::State AccessibleItemInterface::state() const
state.focusable = true;
state.focused = item->accessibleState(IAccessible::State::Focused);
} break;
case IAccessible::Role::SpinBox: {
state.focusable = true;
state.focused = item->accessibleState(IAccessible::State::Focused);
} break;
case IAccessible::Role::Range: {
state.focusable = true;
state.focused = item->accessibleState(IAccessible::State::Focused);
Expand Down Expand Up @@ -225,6 +229,7 @@ QAccessible::Role AccessibleItemInterface::role() const
case IAccessible::Role::List: return QAccessible::List;
case IAccessible::Role::ListItem: return QAccessible::ListItem;
case IAccessible::Role::MenuItem: return QAccessible::MenuItem;
case IAccessible::Role::SpinBox: return QAccessible::SpinBox;
case IAccessible::Role::Range: return QAccessible::Slider;
case IAccessible::Role::Group:
case IAccessible::Role::Information:
Expand Down
5 changes: 4 additions & 1 deletion src/framework/ui/view/qmlaccessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ class MUAccessible
List,
ListItem,
MenuItem,
SpinBox,
Range,
Information
Group,
Information,
ElementOnScore
};
Q_ENUM(Role)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,21 @@ Item {
anchors.top: parent.top
anchors.bottom: parent.bottom

navigation.accessible.role: MUAccessible.SpinBox
navigation.onNavigationEvent: function(event) {
if (!textInputField.activeFocus) {
return
}

switch (event.type) {
case NavigationEvent.Up:
root.increment()
selectAll()
event.accepted = true
break
case NavigationEvent.Down:
root.decrement()
selectAll()
event.accepted = true
break
}
Expand Down Expand Up @@ -191,8 +198,8 @@ Item {
canIncrease: root.canIncrease
canDecrease: root.canDecrease

onIncreaseButtonClicked: { root.increment() }
onDecreaseButtonClicked: { root.decrement() }
onIncreaseButtonClicked: { root.increment(); textInputField.selectAll() }
onDecreaseButtonClicked: { root.decrement(); textInputField.selectAll() }
}

mouseArea.onWheel: function(wheel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ FocusScope {
root.ensureActiveFocus()
}
}

onTriggered: root.ensureActiveFocus()
}

Rectangle {
Expand Down Expand Up @@ -191,6 +193,10 @@ FocusScope {
return
}

if (event.key === Qt.Key_Up || event.key === Qt.Key_Down) {
return;
}

if (textInputModel.isShortcutAllowedOverride(event.key, event.modifiers)) {
event.accepted = true
} else {
Expand Down

0 comments on commit 8dcfb2b

Please sign in to comment.