diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2014-09-22 13:50:17 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2014-09-22 15:18:51 +0200 |
commit | 215ca36081044f5124cc183a2e2ca188bd6aeaf8 (patch) | |
tree | 3ba93b8da86619e18a46d996b91c75c9d22fbb59 /src/controls/ComboBox.qml | |
parent | 01c61ccee62290ec8c7fce3eb97fa403c59736fd (diff) | |
download | qtquickcontrols-215ca36081044f5124cc183a2e2ca188bd6aeaf8.tar.gz |
ComboBox: support toggle combobox menu visibility
Change-Id: If08cac41eef8dafcb45ce46c7cee7d499aa19c18
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/controls/ComboBox.qml')
-rw-r--r-- | src/controls/ComboBox.qml | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 82d718c3..fc8cf321 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -343,14 +343,14 @@ Control { if (comboBox.activeFocusOnPress) forceActiveFocus() if (!Settings.hasTouchScreen) - popup.show() + popup.toggleShow() else overridePressed = true } onCanceled: overridePressed = false onClicked: { if (Settings.hasTouchScreen) - popup.show() + popup.toggleShow() overridePressed = false } onWheel: { @@ -614,14 +614,18 @@ Control { updateSelectedText() } - function show() { - if (items[__selectedIndex]) - items[__selectedIndex].checked = true - __currentIndex = comboBox.currentIndex - if (Qt.application.layoutDirection === Qt.RightToLeft) - __popup(comboBox.width, y, isPopup ? __selectedIndex : 0) - else - __popup(0, y, isPopup ? __selectedIndex : 0) + function toggleShow() { + if (popup.__popupVisible) { + popup.__dismissMenu() + } else { + if (items[__selectedIndex]) + items[__selectedIndex].checked = true + __currentIndex = comboBox.currentIndex + if (Qt.application.layoutDirection === Qt.RightToLeft) + __popup(comboBox.width, y, isPopup ? __selectedIndex : 0) + else + __popup(0, y, isPopup ? __selectedIndex : 0) + } } function updateSelectedText() { @@ -638,8 +642,7 @@ Control { // The key bindings below will only be in use when popup is // not visible. Otherwise, native popup key handling will take place: Keys.onSpacePressed: { - if (!popup.popupVisible) - popup.show() + popup.toggleShow() } Keys.onUpPressed: __selectPrevItem() |