diff options
author | Liang Qi <liang.qi@digia.com> | 2013-02-22 13:44:06 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-12 02:27:29 +0100 |
commit | 2f9d0346f00e37725f0f1bce1318501a25c5e438 (patch) | |
tree | 24060fe2777ada4a054cb0c82e5bf89c28ffa70a /tests/auto/quick/qquickitem2/data | |
parent | b4673e69a0522fca9c592f1dab1734738b1443a8 (diff) |
Support activeFocusOnTab in QQuickItem
Add activeFocusOnTab as property to QQuickItem. Setting the
property allows automatic keyboard navigation between all
elements that have it set.
This key event handler will only be called after the QML key
handlers, such as KeyNavigation and Keys, and the C++ key
event handlers, such as keyPressEvent function.
Algorithm is most done by Frederik Gladhorn, in cooperation with
Gabriel de Dietrich.
Done-with: Frederik Gladhorn <frederik.gladhorn@digia.com>
Done-with: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Change-Id: I8b58be9c20d113661fe85d27bdb1af84340d9de5
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'tests/auto/quick/qquickitem2/data')
-rw-r--r-- | tests/auto/quick/qquickitem2/data/activeFocusOnTab.qml | 136 | ||||
-rw-r--r-- | tests/auto/quick/qquickitem2/data/activeFocusOnTab3.qml | 250 |
2 files changed, 386 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab.qml new file mode 100644 index 0000000000..e064b41efe --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab.qml @@ -0,0 +1,136 @@ +import QtQuick 2.0 + +Item { + id: main + objectName: "main" + width: 800 + height: 600 + focus: true + Component.onCompleted: button12.focus = true + Item { + id: sub1 + objectName: "sub1" + width: 230 + height: 600 + anchors.top: parent.top + anchors.left: parent.left + Item { + id: button11 + objectName: "button11" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + + anchors.top: parent.top + anchors.topMargin: 100 + } + Item { + id: button12 + objectName: "button12" + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + width: 100 + height: 50 + + anchors.top: button11.bottom + anchors.bottomMargin: 100 + } + Item { + id: button13 + objectName: "button13" + enabled: false + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + width: 100 + height: 50 + + anchors.top: button12.bottom + anchors.bottomMargin: 100 + } + Item { + id: button14 + objectName: "button14" + visible: false + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + width: 100 + height: 50 + + anchors.top: button12.bottom + anchors.bottomMargin: 100 + } + } + Item { + id: sub2 + objectName: "sub2" + activeFocusOnTab: true + width: 230 + height: 600 + anchors.top: parent.top + anchors.left: sub1.right + Item { + id: button21 + objectName: "button21" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + + anchors.top: parent.top + anchors.topMargin: 100 + } + Item { + id: button22 + objectName: "button22" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + + anchors.top: button21.bottom + anchors.bottomMargin: 100 + } + } + Item { + id: sub3 + objectName: "sub3" + width: 230 + height: 600 + anchors.top: parent.top + anchors.left: sub2.right + TextEdit { + id: edit + objectName: "edit" + width: 230 + height: 400 + readOnly: false + activeFocusOnTab: true + wrapMode: TextEdit.Wrap + textFormat: TextEdit.RichText + + text: "aaa\n" + +"bbb\n" + +"ccc\n" + +"ddd\n" + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/activeFocusOnTab3.qml b/tests/auto/quick/qquickitem2/data/activeFocusOnTab3.qml new file mode 100644 index 0000000000..00fb82d59e --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/activeFocusOnTab3.qml @@ -0,0 +1,250 @@ +import QtQuick 2.0 + +Item { + id: main + objectName: "main" + width: 400 + height: 700 + focus: true + Component.onCompleted: button1.focus = true + Item { + id: sub1 + objectName: "sub1" + activeFocusOnTab: false + width: 100 + height: 50 + anchors.top: parent.top + Item { + id: button1 + objectName: "button1" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + Row { + id: row_repeater + objectName: "row_repeater" + activeFocusOnTab: false + anchors.top: sub1.bottom + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + Item { + id: sub2 + objectName: "sub2" + activeFocusOnTab: false + anchors.top: row_repeater.bottom + width: 100 + height: 50 + Item { + id: button2 + objectName: "button2" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + Row { + id: row + objectName: "row" + activeFocusOnTab: false + anchors.top: sub2.bottom + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "yellow"; width: 50; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "green"; width: 20; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "blue"; width: 50; height: 20 } + } + Item { + id: sub3 + objectName: "sub3" + activeFocusOnTab: false + anchors.top: row.bottom + width: 100 + height: 50 + Item { + id: button3 + objectName: "button3" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + Flow { + id: flow + objectName: "flow" + activeFocusOnTab: false + anchors.top: sub3.bottom + width: parent.width + anchors.margins: 4 + spacing: 10 + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "yellow"; width: 50; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "green"; width: 20; height: 50 } + Rectangle { activeFocusOnTab: true; color: activeFocus ? "red" : "blue"; width: 50; height: 20 } + } + Item { + id: sub4 + objectName: "sub4" + activeFocusOnTab: false + anchors.top: flow.bottom + width: 100 + height: 50 + Item { + id: button4 + objectName: "button4" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + FocusScope { + id: focusscope + objectName: "focusscope" + activeFocusOnTab: false + anchors.top: sub4.bottom + height: 40 + Row { + id: row_focusscope + objectName: "row_focusscope" + activeFocusOnTab: false + anchors.fill: parent + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + } + Item { + id: sub5 + objectName: "sub5" + activeFocusOnTab: false + anchors.top: focusscope.bottom + width: 100 + height: 50 + Item { + id: button5 + objectName: "button5" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + FocusScope { + id: focusscope2 + objectName: "focusscope2" + activeFocusOnTab: true + anchors.top: sub5.bottom + height: 40 + Row { + id: row_focusscope2 + objectName: "row_focusscope2" + activeFocusOnTab: false + anchors.fill: parent + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + focus: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + } + Item { + id: sub6 + objectName: "sub6" + activeFocusOnTab: false + anchors.top: focusscope2.bottom + width: 100 + height: 50 + Item { + id: button6 + objectName: "button6" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + FocusScope { + id: focusscope3 + objectName: "focusscope3" + activeFocusOnTab: true + anchors.top: sub6.bottom + height: 40 + Row { + id: row_focusscope3 + objectName: "row_focusscope3" + activeFocusOnTab: false + anchors.fill: parent + Repeater { + activeFocusOnTab: false + model: 3 + Rectangle { + activeFocusOnTab: true + width: 100; height: 40 + border.width: 1 + color: activeFocus ? "red" : "yellow" + } + } + } + } + Item { + id: sub7 + objectName: "sub7" + activeFocusOnTab: false + anchors.top: focusscope3.bottom + width: 100 + height: 50 + Item { + id: button7 + objectName: "button7" + width: 100 + height: 50 + activeFocusOnTab: true + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } +} |