I create my custom NSView when a certain button is clicked, and I want to close this custom view if your click outside the NSView. But it seem that I could not receive mouseDown event in this custom NSView. Is there anyone know how to fit it ? Many thanks.
2 Answers
1
votes
I wanted to share two other solutions that unlike the NSEvent approach, doesn't have the sandbox limitations.
A cover window. It's more involved code and a good exercise in learning what's possible with windows and views. But worth learning and knowing.
Create a borderless window that takes up the whole screen. The borderless window can then handle mouse events.
A tracking area. This approach is similar