Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qmlvisual / focusscope / test3.qml
1 import QtQuick 1.0
2
3 /*
4     Currently selected element should be red
5     Pressing "9" should print the number of the currently selected item
6     Be sure to scroll all the way to the right, pause, and then all the way to the left
7 */
8 Rectangle {
9     color: "white"
10     width: 400
11     height: 100
12
13     ListModel {
14         id: model
15         ListElement { name: "red" }
16         ListElement { name: "orange" }
17         ListElement { name: "yellow" }
18         ListElement { name: "green" }
19         ListElement { name: "cyan" }
20         ListElement { name: "blue" }
21         ListElement { name: "indigo" }
22         ListElement { name: "violet" }
23         ListElement { name: "pink" }
24     }
25
26     Component {
27         id: verticalDelegate
28         FocusScope {
29             id: root
30             width: 50; height: 50; 
31             Keys.onDigit9Pressed: console.log("Error - " + name)
32             Rectangle { 
33                 focus: true
34                 Keys.onDigit9Pressed: console.log(name)
35                 width: 50; height: 50; 
36                 color: root.ListView.isCurrentItem?"black":name
37             }
38         }
39     }
40
41     ListView {
42         width: 800; height: 50; orientation: "Horizontal"
43         focus: true
44         model: model
45         delegate: verticalDelegate
46         preferredHighlightBegin: 100
47         preferredHighlightEnd: 101
48         highlightRangeMode: ListView.StrictlyEnforceRange
49     }
50
51
52 }