Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

13679: Focus and accessibility improvements of Spin edit controls #26699

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only SpinBox was needed here but the enum should be in sync with the one in iaccessible.h (there is comment about that) so I added a few missing values.

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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this should be in IncrementalPropertyControl.qml but I figured putting it here shouldn't do any harm. Plus it is much easier to have it here.

return;
}

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