Guest User

Untitled

a guest
Jul 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import Qt 4.7
  2.  
  3. BorderImage {
  4. id: buttonbase
  5.  
  6. signal clicked
  7.  
  8. property int hitboxExtension : 20
  9. property alias text : label.text
  10. property bool pressed: hitbox.pressed && hitbox.containsMouse
  11.  
  12. source: pressed ? "button_down.png" : "button_up.png"
  13.  
  14. border.left: 50;
  15. border.right: 50;
  16.  
  17. MouseArea {
  18. id: hitbox
  19. anchors.fill: parent
  20. anchors.topMargin: -hitboxExtension
  21. anchors.bottomMargin: -hitboxExtension
  22. anchors.leftMargin: -hitboxExtension
  23. anchors.rightMargin: -hitboxExtension
  24.  
  25. onClicked: { haptics.buttonClick(); parent.clicked() }
  26. onPressedChanged: { if (hitbox.pressed) haptics.buttonClick(); }
  27. }
  28.  
  29. Text {
  30. id: label
  31. anchors.centerIn: parent
  32. anchors.verticalCenterOffset: pressed ? -2 : -3
  33. font.family: "Lato Black"
  34. font.pixelSize: 26
  35. color: "#ffffff"
  36. styleColor: "#4f000000"
  37. style: Text.Sunken
  38. }
  39. }
Add Comment
Please, Sign In to add comment