diff options
author | Thomas Zander <t.zander@nokia.com> | 2010-08-06 14:09:50 +0200 |
---|---|---|
committer | Thomas Zander <t.zander@nokia.com> | 2010-08-06 14:09:50 +0200 |
commit | de9d7184fa5408d90ac06f46a32f321cd0e186ca (patch) | |
tree | 808ccefc9f20c9d67beec62a3343f8fb996fc229 /stroke-list | |
parent | c825d3d810a631997370600966bbe74b8727d996 (diff) |
Follow changes in gesture area to now have onUpdated etc.
Diffstat (limited to 'stroke-list')
-rw-r--r-- | stroke-list/Button.qml | 62 | ||||
-rw-r--r-- | stroke-list/main.qml | 18 |
2 files changed, 35 insertions, 45 deletions
diff --git a/stroke-list/Button.qml b/stroke-list/Button.qml index 1c17068..b53d54a 100644 --- a/stroke-list/Button.qml +++ b/stroke-list/Button.qml @@ -117,45 +117,39 @@ Rectangle { anchors.fill: parent Tap { - when: button.enabled && gesture.state == Qt.GestureStarted - script: { button.state = "pressed" } - } - Tap { - when: button.enabled && !button.handled && gesture.state == Qt.GestureCanceled - script: { button.state = ""; } - } - Tap { - when: button.enabled && !button.handled && gesture.state == Qt.GestureFinished - script: { button.state = ""; button.increaseCounter(); } - } - Tap { - when: gesture.state == Qt.GestureFinished - script: { button.handled = false; } + when: button.enabled + onStarted: { button.state = "pressed" } + onCanceled: { + if (!button.handled) { + button.state = ""; + } + } + onFinished: { + if (!button.handled) { + button.state = ""; + button.increaseCounter(); + } + button.handled = false; + } } + TapAndHold { - when: button.enabled && gesture.state == Qt.GestureFinished - script: { console.log("tap-and-hold"); button.toggleMark() } + when: button.enabled + onFinished: { console.log("tap-and-hold"); button.toggleMark() } } Swipe { - when: gesture.state == Qt.GestureFinished - && isHorizontalSwipe(gesture.swipeAngle) - && gesture.horizontalDirection == SwipeGesture.Left - script: button.state = "" - } - Swipe { - when: gesture.state == Qt.GestureFinished - && isHorizontalSwipe(gesture.swipeAngle) - && gesture.horizontalDirection == SwipeGesture.Right - script: button.state = "disabled" - } - Swipe { - when: gesture.state == Qt.GestureStarted - script: button.handled = true - } - Swipe { - when: gesture.state == Qt.GestureFinished - script: button.handled = false + onStarted: button.handled = true + onFinished: { + if (isHorizontalSwipe(gesture.swipeAngle)) { + if (gesture.horizontalDirection == SwipeGesture.Right) { + button.state = "disabled" + } else if (gesture.horizontalDirection == SwipeGesture.Left) { + script: button.state = "" + } + } + button.handled = false + } } } } diff --git a/stroke-list/main.qml b/stroke-list/main.qml index 019b636..edf1fed 100644 --- a/stroke-list/main.qml +++ b/stroke-list/main.qml @@ -35,19 +35,15 @@ Rectangle { property bool panEnabled : false Pan { - when: parent.panEnabled - script: list.y += gesture.delta.y - } - Pan { - when: !parent.panEnabled - script: { - if (Math.abs(gesture.offset.y) >= 10 && Math.abs(gesture.offset.x) < 10) + onUpdated: { + if (parent.panEnabled) + list.y += gesture.delta.y + else if (Math.abs(gesture.offset.y) >= 10 && Math.abs(gesture.offset.x) < 10) parent.panEnabled = true } - } - Pan { - when: parent.panEnabled && gesture.state == Qt.GestureFinished - script: parent.panEnabled = false + onFinished: { + parent.panEnabled = false + } } } } |