Hi,

I'm having problem catching the outside click of my custom combobox item to hide the dropdown.
Any help is greatly appreciated. TIA.

CustomComboBox.qml
Qt Code:
  1. FocusScope
  2. {
  3.  
  4. MouseArea
  5. {
  6. id: mouseArea
  7. anchors.fill: container
  8. onClicked: { container.focus = true; toggle() }
  9. onExited: close()
  10. }
  11.  
  12. Rectangle
  13. {
  14. id: dropDown
  15. // some codes for ListView to delegate list items
  16. states: [
  17. State {
  18. name: "visible";
  19. PropertyChanges { target: dropDown; height: container.height * listView.count }
  20. }
  21. ]
  22. }
  23.  
  24. function toggle() {
  25. if (dropDown.state === "visible") { close(false) } else { open() }
  26. }
  27.  
  28. function open() {
  29. dropDown.state = "visible"
  30. }
  31.  
  32. function close(update) {
  33. dropDown.state = ""
  34. }
  35. }
To copy to clipboard, switch view to plain text mode 

Main.qml
Qt Code:
  1. Rectangle
  2. {
  3. CustomComboBox
  4. {
  5. id: textCmb
  6. }
  7.  
  8. Mousearea
  9. {
  10. onClicked: // here i'm having problem hiding the dropdown of textCmb
  11.  
  12. }
  13. }
To copy to clipboard, switch view to plain text mode 

*PS: I have many comboBoxes on main.qml