diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-04-24 12:07:46 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2017-04-24 13:37:02 +0000 |
commit | 039c25daac5ec6b96c0aa074eae2a983a1b5aabd (patch) | |
tree | e8fb889ce6bedae2664a37a9c0d138f9bddd2401 /src/quicktemplates2/qquickspinbox.cpp | |
parent | 743d0132fe006699dd33e5b4254a36f4e2ec7f9f (diff) |
Forward focus to the contentItem of editable spinboxes
This fixes the scenario where a SpinBox is shown for the first time
with focus, but its editor (TextInput) doesn't have active focus.
tst_focus' keyNavigation.qml had to be adjusted, as an editable
spinbox will now consume key events.
Task-number: QTBUG-60356
Change-Id: I3af0260a22e9633ab6110d6adab7b39a22b849de
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickspinbox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickspinbox.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index b6e99609..a41383aa 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -719,6 +719,16 @@ void QQuickSpinBox::decrease() setValue(d->value - d->effectiveStepSize()); } +void QQuickSpinBox::focusInEvent(QFocusEvent *event) +{ + Q_D(QQuickSpinBox); + QQuickControl::focusInEvent(event); + + // When an editable SpinBox gets focus, it must pass on the focus to its editor. + if (d->editable && d->contentItem && !d->contentItem->hasActiveFocus()) + d->contentItem->forceActiveFocus(event->reason()); +} + void QQuickSpinBox::hoverEnterEvent(QHoverEvent *event) { Q_D(QQuickSpinBox); |