2
votes

I have my standard app setup, window with lots of views. From time to time I place an NSView over the top of everything, black with some transparency, to act an a dimmer/overlay.

I need this top overlay view to absorb all clicks so that any views underneath it can't be interacted with. E.g. an NSButton under this NSView won't be clickable.

How can I do this?

I have seen -(NSView *)hitTest:(NSPoint)aPoint but I don't want to put this on every single subview with a rule to block clicks while the overlay view is present.

1
If you have a view that covers the entire window I believe the views underneath should not receive any mouse events. Otherwise try override mouseDown: (with nothing in it).TheAmateurProgrammer
Well that did the trick! I didn't realise that would work. I could click through the NSView until adding an empty mouseDown method as you mention. Thanks! Feel free to make it an official answer.Josh Kahane

1 Answers

5
votes

Override the NSView with an empty mouseDown: and the views underneath will not receive any mouse events.