diff options
| author | selsta <selsta@sent.at> | 2019-01-22 22:20:42 +0100 |
|---|---|---|
| committer | selsta <selsta@sent.at> | 2019-01-23 16:09:49 +0100 |
| commit | eec1560ead8e613aa37e99658803957c06dd0c5a (patch) | |
| tree | cc9629be0c503a21ffa92b34d564f87207ca9480 | |
| parent | 9689fff957ba994b619a2a7fb881598a997f66c2 (diff) | |
| download | monzero-gui-eec1560ead8e613aa37e99658803957c06dd0c5a.tar.gz monzero-gui-eec1560ead8e613aa37e99658803957c06dd0c5a.tar.xz monzero-gui-eec1560ead8e613aa37e99658803957c06dd0c5a.zip | |
IconButton: fix mousearea and animation
Co-authored-by: mmbyday <mmbyday@protonmail.com>
| -rw-r--r-- | components/IconButton.qml | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/components/IconButton.qml b/components/IconButton.qml index 801c01e9..ba6d1e94 100644 --- a/components/IconButton.qml +++ b/components/IconButton.qml @@ -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) } } - } |
