diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-04-29 15:35:26 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-30 13:59:13 +0200 |
commit | 0bba341da5e5d0c78c17f6a00e75fad804315e77 (patch) | |
tree | a43017aa20684439f4e6d94d41155f3e942a07cb /src/controls/Button.qml | |
parent | 153770998e3eceda6d5237e995a70a3ed00d7cfa (diff) | |
download | qtquickcontrols-0bba341da5e5d0c78c17f6a00e75fad804315e77.tar.gz |
Button: Add 'menu' property to get pull-down button
Change-Id: I97ce3f35153beee2d7b1113880f25fd01904ce5f
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/Button.qml')
-rw-r--r-- | src/controls/Button.qml | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/controls/Button.qml b/src/controls/Button.qml index ff84aecd..ccf1973b 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -83,9 +83,46 @@ BasicButton { */ property url iconSource + /*! Assign a \l Menu to this property to get a pull-down menu button. + + The default value is \c null. + */ + property Menu menu: null + activeFocusOnTab: true Accessible.name: text style: Qt.createComponent(Settings.theme() + "/ButtonStyle.qml", button) + + readonly property bool pressed: __behavior.effectivePressed || menu && menu.__popupVisible + + Binding { + target: menu + property: "__minimumWidth" + value: button.__panel.width + } + + Binding { + target: menu + property: "__visualItem" + value: button + } + + Connections { + target: __behavior + onEffectivePressedChanged: { + if (__behavior.effectivePressed && menu) + popupMenuTimer.start() + } + } + + Timer { + id: popupMenuTimer + interval: 10 + onTriggered: { + __behavior.keyPressed = false + menu.__popup(0, button.height, 0) + } + } } |