X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmdictionary%2Fqml%2FComboBox.qml;h=56a0a401cfdc92590944ad9b1fbad1a56df4ac82;hb=9a5bedfd71b6c1a09fe77aea909d3d78a771a6e8;hp=5ceb5b578b17e9ba0197b9bc5531d675c25c5504;hpb=11ada56e37ed724c4777ad2ac555eabe19c65c12;p=mdictionary diff --git a/src/mdictionary/qml/ComboBox.qml b/src/mdictionary/qml/ComboBox.qml index 5ceb5b5..56a0a40 100644 --- a/src/mdictionary/qml/ComboBox.qml +++ b/src/mdictionary/qml/ComboBox.qml @@ -27,18 +27,10 @@ Rectangle { signal valueSelected(string selected); - /* Keys.onPressed: { - console.log("tu ----"); - if (event.key == Qt.Key_Escape) - rectangle1.expanded=false; - else if (event.key == Qt.Key_Space) + Keys.onPressed: { + if (event.key == Qt.Key_Space) rectangle1.expanded=true; - else if (event.key == Qt.Key_Return){ - rectangle1.expanded=false; - console.log("tu enter "+list1.content); - } } - */ Text { id: text1 @@ -96,6 +88,17 @@ Rectangle { visible: false property string selected: rectangle1.startValue + Keys.onPressed: { + + if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){ + selectedValue(currentIndex, model.valueOnPosition(currentIndex)) + } + if (event.key == Qt.Key_Escape){ + rectangle1.show(!rectangle1.expanded) + event.accepted = true + } + } + function selectedValue(nr, value) { currentIndex = nr selected = value