From f605793cfcd15298579b08580fb37458a2c0e001 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Tue, 8 Aug 2017 10:37:52 +0200 Subject: [PATCH] components android focus workaround --- components/MenuButton.qml | 9 ++++++++- components/StandardButton.qml | 12 +++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/components/MenuButton.qml b/components/MenuButton.qml index 0e33057c..23ab4f74 100644 --- a/components/MenuButton.qml +++ b/components/MenuButton.qml @@ -38,6 +38,13 @@ Rectangle { property var under: null signal clicked() + function doClick() { + // Android workaround + releaseFocus(); + clicked(); + } + + function getOffset() { var offset = 0 var item = button @@ -139,7 +146,7 @@ Rectangle { onClicked: { if(parent.checked) return - button.clicked() + button.doClick() parent.checked = true } } diff --git a/components/StandardButton.qml b/components/StandardButton.qml index c55ebb12..3954c58c 100644 --- a/components/StandardButton.qml +++ b/components/StandardButton.qml @@ -45,6 +45,12 @@ Item { // Dynamic label width Layout.minimumWidth: (label.contentWidth + 10 * scaleRatio) // (label.contentWidth > 80)? label.contentWidth + 20 : 100 + function doClick() { + // Android workaround + releaseFocus(); + clicked(); + } + Rectangle { anchors.left: parent.left anchors.right: parent.right @@ -98,9 +104,9 @@ Item { MouseArea { id: buttonArea anchors.fill: parent - onClicked: parent.clicked() + onClicked: doClick() } - Keys.onSpacePressed: clicked() - Keys.onReturnPressed: clicked() + Keys.onSpacePressed: doClick() + Keys.onReturnPressed: doClick() }