diff options
Diffstat (limited to 'DemoApplication/pages')
-rw-r--r-- | DemoApplication/pages/Page1.qml | 78 | ||||
-rw-r--r-- | DemoApplication/pages/Page2.qml | 122 | ||||
-rw-r--r-- | DemoApplication/pages/Page3.qml | 93 |
3 files changed, 293 insertions, 0 deletions
diff --git a/DemoApplication/pages/Page1.qml b/DemoApplication/pages/Page1.qml new file mode 100644 index 0000000..b73be48 --- /dev/null +++ b/DemoApplication/pages/Page1.qml @@ -0,0 +1,78 @@ +import QtQuick 2.9 + +import CursorNavigation 1.0 +import "../controls" + +Item { + width: parent.width + height: parent.height + + FocusScope { + anchors.fill: parent + + Item { + width: 500 + height: 400 + anchors.centerIn: parent + + CNButton { + id: button + x: 52 + y: 50 + text: qsTr("Button") + } + + CNButton { + id: button1 + x: 110 + y: 138 + text: qsTr("Button") + } + + CNButton { + id: button2 + x: 160 + y: 241 + text: qsTr("Button with default focus") + focus: true + } + + CNButton { + id: button3 + x: 383 + y: 241 + text: qsTr("Button") + } + + CNButton { + id: button4 + x: 383 + y: 322 + text: qsTr("Button") + } + + CNButton { + id: button5 + x: 383 + y: 138 + text: qsTr("Button") + } + + CNButton { + id: button6 + x: 383 + y: 50 + text: qsTr("Button") + } + + CNButton { + id: button7 + x: 62 + y: 241 + text: qsTr("Button") + } + } + //this seems to be the way to force focus on a newly opened dialog? + Component.onCompleted: { forceActiveFocus(); } + } +} diff --git a/DemoApplication/pages/Page2.qml b/DemoApplication/pages/Page2.qml new file mode 100644 index 0000000..c655170 --- /dev/null +++ b/DemoApplication/pages/Page2.qml @@ -0,0 +1,122 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.4 + +import CursorNavigation 1.0 +import "../controls" + +Item { + width: parent.width + height: parent.height + + Item { + width: 580 + height: 450 + anchors.centerIn: parent + FocusScope { + id: focusScope + width: 198 + height: 359 + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: 20 + + CursorNavigation.acceptsCursor: true + ListView { + id: listView + anchors.fill: parent + spacing: 4 + focus: true + + Rectangle { + anchors.fill: parent + visible: listView.activeFocus + border.width: 2 + border.color: "red" + color: "transparent" + } + + highlight: Rectangle { + width: listView.width + height: 40 + color: "lightgrey" + opacity: 0.3 + } + + delegate: ItemDelegate { + width: listView.width + height: 40 + + contentItem: Row { + width: (parent.width - x) + height: 35 + x: 5 + anchors.verticalCenter: parent.verticalCenter + spacing: 10 + Rectangle { + width: parent.height + height: parent.height + radius: width/2 + color: colorCode + } + Text { + height: parent.height + font.bold: true + verticalAlignment: Text.AlignVCenter + text: name + } + } + onClicked: { + listView.currentIndex = index; + } + } + + model: ListModel { + ListElement { + name: "Grey" + colorCode: "grey" + } + + ListElement { + name: "Red" + colorCode: "red" + } + + ListElement { + name: "Blue" + colorCode: "blue" + } + + ListElement { + name: "Green" + colorCode: "green" + } + } + } + } + CNButton { + id: button3 + anchors.top: focusScope.bottom + anchors.topMargin: 20 + anchors.right: parent.right + anchors.rightMargin: 60 + text: qsTr("Button") + } + Column { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 50 + spacing: 30 + CNButton { + text: qsTr("Button") + } + + CNButton { + text: qsTr("Button") + } + + CNButton { + text: qsTr("Button") + } + } + } +} 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(); } + } +} |