first (buggy) version of keyboard usage in qml list
[mdictionary] / src / mdictionary / qml / ElementsListView.qml
index d365763..fa53b93 100644 (file)
@@ -1,6 +1,51 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+/*!
+    author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
 import Qt 4.7
 
 ListView {
-    property int selectedElement: -1
+    anchors.fill: parent
+    focus: true
+    currentIndex: 0
+    highlight: Rectangle { color: "lightsteelblue"; radius: 5; width: parent.parent.width }
+    highlightMoveSpeed: 1000
+
+    function setFocus() {
+        console.log("juhu2")
+        forceActiveFocus()
+//        console.log(focus + " " + activeFocus)
+    }
+
+    Keys.onPressed: {
+        console.log("woooo")
+        if (event.key == Qt.Key_Up && currentIndex < count){
+            currentIndex = currentIndex + 1
+            console.log("woooo222 " + currentIndex)
+        } else if (event.key == Qt.Key_Down && currentIndex > 0){
+            currentIndex = currentIndex - 1
+            console.log("woooo333 " + currentIndex)
+        }
+    }
 
 }