Hi,

This is a working code, i just want some advise:

Button.qml
Qt Code:
  1. Item
  2. {
  3. property alias text: label.text
  4. property bool pressed: false
  5.  
  6. property int btnHeight: Functions.buttonHeight
  7.  
  8. id: button
  9. height: btnHeight
  10.  
  11. Rectangle
  12. {
  13. id: rec
  14. anchors.fill: parent
  15. color: pressed ? "#226EEA" : "#1150B7"
  16. }
  17.  
  18. Text {
  19. id: label
  20. color: "white"
  21. }
  22. }
To copy to clipboard, switch view to plain text mode 

Otherfile.qml
Qt Code:
  1. Button
  2. {
  3. id: doneBtn
  4. text: qsTr("Done")
  5.  
  6. MouseArea
  7. {
  8. anchors.fill: parent
  9. onClicked: {
  10. //some codes
  11. }
  12. onPressed: { doneBtn.pressed = true }
  13. onReleased: { doneBtn.pressed = false }
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 

Here are my questions:
1. I'm having problem when I put a mouse area on Button.qml, it will be overriden by the mouse area set from other file. I wanted to put the onPressed and onReleased in Button.qml, so that I don't have to write it down in every mouse area of each buttons.
2. I read somewhere that it is advisable not to put mouse area in reuseable elements, is that correct?
3. Can you please advise how to revise the code, not exactly an actual code but some tips.

TIA.