summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-08-12 01:31:25 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-08-12 01:31:25 (GMT)
commit6fc7ce61ba1b623421ca3ca8ee2315746be0a37b (patch)
tree6ea9c57eaca6996a2e842604b50df1b224941c96 /examples/declarative
parent14466ace2ffe1b6707b1120ab76d0baa49635007 (diff)
downloadQt-6fc7ce61ba1b623421ca3ca8ee2315746be0a37b.zip
Qt-6fc7ce61ba1b623421ca3ca8ee2315746be0a37b.tar.gz
Qt-6fc7ce61ba1b623421ca3ca8ee2315746be0a37b.tar.bz2
Change key handling to use a Keys attached property.
Replaces KeyAction, allowing focus to be set on the actual item that wants focus, rather than a separate handler item.
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/snow/snow.qml17
1 files changed, 8 insertions, 9 deletions
diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml
index aed426f..5dd0006 100644
--- a/examples/declarative/snow/snow.qml
+++ b/examples/declarative/snow/snow.qml
@@ -48,23 +48,22 @@ Rect {
}
Script {
- function leftPressed() {
+ function left() {
if (selectedItemColumn <= 0) return;
selectedItemColumn -= 1;
MyLayout.slowDeform = false;
MyLayout.targetDeform = Math.max(Math.min(MyLayout.deform - 0.1, -0.1), -0.4);
}
- function rightPressed() {
+ function right() {
selectedItemColumn += 1;
MyLayout.slowDeform = false;
MyLayout.targetDeform = Math.min(Math.max(MyLayout.deform + 0.1, 0.1), 0.4);
}
}
- KeyActions {
- focus: true
- leftArrow: "leftPressed()"
- rightArrow: "rightPressed()"
- upArrow: "if (selectedItemRow > 0) selectedItemRow = selectedItemRow - 1"
- downArrow: "if (selectedItemRow < 3) selectedItemRow = selectedItemRow + 1"
- }
+
+ focus: true
+ Keys.onLeftPressed: "left()"
+ Keys.onRightPressed: "right()"
+ Keys.onUpPressed: "if (selectedItemRow > 0) selectedItemRow = selectedItemRow - 1"
+ Keys.onDownPressed: "if (selectedItemRow < 3) selectedItemRow = selectedItemRow + 1"
}