add focus in qml
[mdictionary] / src / mdictionary / qml / IconButton.qml
index 9be44f1..37825a7 100644 (file)
@@ -33,17 +33,16 @@ Rectangle {
 
     Image {
         id: image1
-        z: 1
         smooth: true
-        width: (35*parent.height)/107 +1
+        width:  (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1 //(35*parent.height)/107 +1
         height: parent.height
         anchors.left: parent.left
         source: "qrc:/button/buttonLeft.png"
+        fillMode:Image.Stretch
     }
 
     Image {
         id: image3
-        z: 1
         smooth: true
         height: parent.height
         anchors.right: image2.left
@@ -51,18 +50,20 @@ Rectangle {
         anchors.left: image1.right
         anchors.leftMargin: -1
         source: "qrc:/button/buttonCenter.png"
+        fillMode:Image.Stretch
+        //fillMode: Image.TileHorizontally
 
     }
 
 
     Image {
         id: image2
-        z: 1
         smooth: true
-        width: (35*parent.height)/107 +1
+        width: (image1.sourceSize.width*parent.height)/image1.sourceSize.height +1//(35*parent.height)/107 +1
         height: parent.height
         anchors.right: parent.right
         source: "qrc:/button/buttonR.png"
+        fillMode:Image.Stretch
     }
 
 
@@ -80,6 +81,14 @@ Rectangle {
             PropertyChanges { target: image1; source: "qrc:/button/buttonLeftPushed.png" }
             PropertyChanges { target: image3; source: "qrc:/button/buttonCenterPushed.png" }
             PropertyChanges { target: image2; source: "qrc:/button/buttonRightPushed.png" }
+        },
+        State {
+            name: "focused";
+            when: (rectangle.enabled && !mouseArea.pressed && rectangle.focus)
+
+            PropertyChanges { target: image1; source: "qrc:/button/buttonLeftFocus.png" }
+            PropertyChanges { target: image3; source: "qrc:/button/buttonCenterFocus.png" }
+            PropertyChanges { target: image2; source: "qrc:/button/buttonRFocus.png" }
         }
     ]
 }