diff options
author | Martin Klapetek <mklapetek@kde.org> | 2013-12-03 18:02:54 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-04 12:52:03 +0100 |
commit | 8bea832b49c059f167a3797083e7b0b82217fb00 (patch) | |
tree | c6fe3db123a0a69cf6b2a4e76dd071ee6008f478 | |
parent | eb69975cbc667d36e56795e2af2761835916e152 (diff) | |
download | qtquickcontrols-8bea832b49c059f167a3797083e7b0b82217fb00.tar.gz |
Make scrolling on combobox work
Handles mouse scrolling event over combobox - scrolling up does the same
as pressing up arrow and scrolling down equals pressing down arrow.
Change-Id: I67adef46f201c0d4c88dabd5a717effc8f1e909d
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
-rw-r--r-- | src/controls/ComboBox.qml | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index d7a3d3d1..81c8588d 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -268,6 +268,28 @@ Control { } /*! \internal */ + function __selectPrevItem() { + input.blockUpdate = true + if (currentIndex > 0) { + currentIndex--; + input.text = popup.currentText; + activated(currentIndex); + } + input.blockUpdate = false; + } + + /*! \internal */ + function __selectNextItem() { + input.blockUpdate = true; + if (currentIndex < popupItems.count - 1) { + currentIndex++; + input.text = popup.currentText; + activated(currentIndex); + } + input.blockUpdate = false; + } + + /*! \internal */ property var __popup: popup style: Qt.createComponent(Settings.style + "/ComboBoxStyle.qml", comboBox) @@ -285,6 +307,13 @@ Control { forceActiveFocus() popup.show() } + onWheel: { + if (wheel.angleDelta.y > 0) { + __selectPrevItem(); + } else if (wheel.angleDelta.y < 0){ + __selectNextItem(); + } + } } Component.onCompleted: { @@ -541,23 +570,6 @@ Control { popup.show() } - Keys.onUpPressed: { - input.blockUpdate = true - if (currentIndex > 0) { - currentIndex--; - input.text = popup.currentText; - activated(currentIndex); - } - input.blockUpdate = false; - } - - Keys.onDownPressed: { - input.blockUpdate = true; - if (currentIndex < popupItems.count - 1) { - currentIndex++; - input.text = popup.currentText; - activated(currentIndex); - } - input.blockUpdate = false; - } + Keys.onUpPressed: __selectPrevItem() + Keys.onDownPressed: __selectNextItem() } |