add focus in qml
[mdictionary] / src / mdictionary / qml / Checkbox.qml
index 7e96512..75046e3 100644 (file)
@@ -32,6 +32,12 @@ Image {
     property string pathToCheckedDicImage: "qrc:/button/checkboxCheckedDis.png"
     property string pathToUncheckedDicImage: "qrc:/button/checkboxDis.png"
     signal changed
+
+    Keys.onPressed: {
+        if (event.key == Qt.Key_Space)
+            selected=!selected
+    }
+
     height: {
         var aspectRatio = sourceSize.height / sourceSize.width
         return checkbox.width * aspectRatio
@@ -74,4 +80,21 @@ Image {
             }
         }
     }
+
+    Rectangle{
+        id: focusRectangle
+        color: "#000000"
+        border.color: "#000000"
+        opacity: 0;
+        radius: 1
+        anchors.centerIn: parent
+        z:1;
+    }
+
+    onFocusChanged: {
+        if(focus)
+            focusRectangle.opacity=0.5;
+        else
+            focusRectangle.opacity=0;
+    }
 }