diff options
Diffstat (limited to 'DemoApplication/pages/Page3.qml')
-rw-r--r-- | DemoApplication/pages/Page3.qml | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/DemoApplication/pages/Page3.qml b/DemoApplication/pages/Page3.qml new file mode 100644 index 0000000..ece6975 --- /dev/null +++ b/DemoApplication/pages/Page3.qml @@ -0,0 +1,93 @@ +import QtQuick 2.0 + +import CursorNavigation 1.0 +import "../controls" + +Item { + width: parent.width + height: parent.height + + FocusScope { + id: rootScope + anchors.fill: parent + Row { + anchors.centerIn: parent + spacing: 10 + CNButton { + width: 100 + height: 100 + text: "alone!" + } + + Grid { + columns: 2 + rows: 2 + spacing: 5 + + CNButton { + text: "b1" + } + + CNButton { + text: "b2 (default focus)" + focus: true + } + + CNButton { + id: defaultButton + text: "b3 (escape target)" + } + + CNButton { + text: "b4" + } + } + + Rectangle { + width: 250 + height: 200 + + border.width: 2 + border.color: "grey" + + FocusScope { + anchors.fill: parent + CursorNavigation.acceptsCursor: true + CursorNavigation.escapeTarget: defaultButton + + //redefine the controls for this scope + //(default arrow keys will still work as well, unless reassigned here) + Keys.onDigit5Pressed: CursorNavigation.moveUp() + Keys.onDigit2Pressed: CursorNavigation.moveDown() + Keys.onDigit3Pressed: CursorNavigation.moveRight() + Keys.onDigit1Pressed: CursorNavigation.moveLeft() + + Grid { + spacing: 5 + columns: 2 + rows: 2 + + CNButton { + text: "sb1" + } + + CNButton { + text: "sb2" + } + + CNButton { + text: "sb3" + } + + CNButton { + text: "sb4 (default focus)" + focus: true + } + } + } + } + } + //this seems to be the way to force focus on a newly opened dialog? + Component.onCompleted: { forceActiveFocus(); } + } +} |