ToolButton: Improve keyboard navigation support

Use the hover frame to indicate focus, do not give focus if keyboard
navigation is not defined.

REVIEW: 104727
This commit is contained in:
Aurélien Gâteau 2012-04-25 12:36:00 +02:00
parent 47d42a6d36
commit 90bddbf61e

View File

@ -80,11 +80,6 @@ Item {
enabled: defaultAction==undefined||defaultAction.enabled
onFlatChanged: {
surface.opacity = 1
}
implicitWidth: {
if (label.paintedWidth == 0) {
return implicitHeight
@ -134,7 +129,13 @@ Item {
}
button.clicked()
button.forceActiveFocus()
if (button.KeyNavigation.tab || button.KeyNavigation.backtab) {
// Only focus the button if it is set up for keyboard
// navigation. This avoid getting a strange focus frame around
// buttons which are usually not focusable, such as buttons in
// a toolbar.
button.forceActiveFocus();
}
if (defaultAction) {
defaultAction.trigger()
@ -155,7 +156,7 @@ Item {
imagePath: "widgets/button"
prefix: (internal.userPressed || checked) ? "pressed" : "normal"
//internal: if there is no hover status, don't paint on mouse over in touchscreens
opacity: (internal.userPressed || checked || !flat || (shadow.hasOverState && mouse.containsMouse)) ? 1 : 0
opacity: (internal.userPressed || checked || !flat || parent.activeFocus || (shadow.hasOverState && mouse.containsMouse)) ? 1 : 0
Behavior on opacity {
PropertyAnimation { duration: 100 }
}