diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-22 18:04:59 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-24 08:15:46 +0000 |
commit | 8a4db8ec31426a3ca2697ec868f566ba43bbe597 (patch) | |
tree | de02f6e7f325b54621eb55c0cb4485d38360c433 /tests/auto/controls | |
parent | 859663ae2971f3b6b99239dda24782eda2d88347 (diff) |
RangeSlider: forward focus to the handles
The active focus ends up to RangeSlider when using forceActiveFocus()
or QML KeyNavigation. We must forward the focus to one of the handles,
because RangeSlider handles key events for the focused handle. If
neither handle has active focus, RangeSlider doesn't do anything.
Change-Id: I61a53d0c7203fad64306b54c1f96093bd9312416
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'tests/auto/controls')
-rw-r--r-- | tests/auto/controls/data/tst_rangeslider.qml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index 97104856..cc12b851 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -655,4 +655,38 @@ TestCase { control.destroy() } + + function test_focus() { + var control = sliderComponent.createObject(testCase) + verify(control) + + waitForRendering(control) + compare(control.activeFocus, false) + + // focus is forwarded to the first handle + control.forceActiveFocus() + compare(control.activeFocus, true) + compare(control.first.handle.activeFocus, true) + compare(control.second.handle.activeFocus, false) + + // move focus to the second handle + control.second.handle.forceActiveFocus() + compare(control.activeFocus, true) + compare(control.first.handle.activeFocus, false) + compare(control.second.handle.activeFocus, true) + + // clear focus + control.focus = false + compare(control.activeFocus, false) + compare(control.first.handle.activeFocus, false) + compare(control.second.handle.activeFocus, false) + + // focus is forwarded to the second handle (where it previously was in the focus scope) + control.forceActiveFocus() + compare(control.activeFocus, true) + compare(control.first.handle.activeFocus, false) + compare(control.second.handle.activeFocus, true) + + control.destroy() + } } |