Is it possible to make a NSBox clickable (like a NSButton) in Swift macOS?

449 views Asked by At

I have a NSBox with some labels inside it, that I want to act as a button. Is this possible, or do I have to find some other way to make large areas of an application clickable?

2

There are 2 answers

0
AglaiaZ On

Yes, use the func mouseDown event. You can also do this based on location. Also, if you’re working with the sks file you can always create a transparent button on top (assuming the box with labels is stationary)...

0
Gabriel Roth On

As a subclass of NSView, NSBox responds to the mouseDown event. More information at https://developer.apple.com/documentation/appkit/nsresponder/1524634-mousedown