Only draw the focus indicator when we got focus via the keyboard

QQC2 controls gain activeFocus on press this is a difference to controls 1
which had activeFocusOnPress property that defaulted to false. qqc2-desktop-style
also only sets the focus flag if it was gained via keyboard (kquickstyleitem.cpp:705).
BUG:424446
This commit is contained in:
David Redondo 2020-07-20 10:46:30 +02:00
parent 711789908b
commit 3e225d8664

View File

@ -108,14 +108,16 @@ T.ToolButton {
background: Item {
Private.ButtonShadow {
anchors.fill: parent
visible: (!control.flat || control.hovered || control.activeFocus) && (!control.pressed || !control.checked)
readonly property bool keyboardFocus: control.activeFocus &&
(control.focusReason == Qt.TabFocusReason || control.focusReason == Qt.BacktabFocusReason)
visible: (!control.flat || control.hovered || keyboardFocus) && (!control.pressed || !control.checked)
state: {
if (control.pressed) {
return "hidden"
} else if (control.hovered) {
return "hover"
} else if (control.activeFocus) {
} else if (keyboardFocus) {
return "focus"
} else {
return control.flat ? "shadow" : "hidden"