Merge pull request #1907

eec1560 IconButton: fix mousearea and animation (selsta)
This commit is contained in:
luigi1111 2019-02-01 01:05:32 -06:00
commit d2113686ab
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010

View File

@ -35,7 +35,6 @@ Item {
signal clicked(var mouse)
id: button
width: parent.height
height: parent.height
@ -47,13 +46,13 @@ Item {
id: buttonImage
source: ""
x : (parent.width - width) / 2
y : (parent.height - height) /2
y : (parent.height - height) / 2
z: 100
}
MouseArea {
id: buttonArea
anchors.fill: parent
anchors.fill: buttonImage
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
@ -61,14 +60,21 @@ Item {
buttonImage.x = buttonImage.x + 2
buttonImage.y = buttonImage.y + 2
}
onReleased: {
buttonImage.x = buttonImage.x - 2
buttonImage.y = buttonImage.y - 2
buttonImage.x = (parent.width - width) / 2
buttonImage.y = (parent.height - height) / 2
}
onExited: {
if (pressed) {
buttonImage.x = (parent.width - width) / 2
buttonImage.y = (parent.height - height) / 2
}
}
onClicked: {
parent.clicked(mouse)
}
}
}