components android focus workaround

This commit is contained in:
Jaquee 2017-08-08 10:37:52 +02:00
parent b6f268d3a5
commit f605793cfc
2 changed files with 17 additions and 4 deletions

View File

@ -38,6 +38,13 @@ Rectangle {
property var under: null property var under: null
signal clicked() signal clicked()
function doClick() {
// Android workaround
releaseFocus();
clicked();
}
function getOffset() { function getOffset() {
var offset = 0 var offset = 0
var item = button var item = button
@ -139,7 +146,7 @@ Rectangle {
onClicked: { onClicked: {
if(parent.checked) if(parent.checked)
return return
button.clicked() button.doClick()
parent.checked = true parent.checked = true
} }
} }

View File

@ -45,6 +45,12 @@ Item {
// Dynamic label width // Dynamic label width
Layout.minimumWidth: (label.contentWidth + 10 * scaleRatio) // (label.contentWidth > 80)? label.contentWidth + 20 : 100 Layout.minimumWidth: (label.contentWidth + 10 * scaleRatio) // (label.contentWidth > 80)? label.contentWidth + 20 : 100
function doClick() {
// Android workaround
releaseFocus();
clicked();
}
Rectangle { Rectangle {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
@ -98,9 +104,9 @@ Item {
MouseArea { MouseArea {
id: buttonArea id: buttonArea
anchors.fill: parent anchors.fill: parent
onClicked: parent.clicked() onClicked: doClick()
} }
Keys.onSpacePressed: clicked() Keys.onSpacePressed: doClick()
Keys.onReturnPressed: clicked() Keys.onReturnPressed: doClick()
} }