Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to block NSView events under another NSView?

Here is the idea:

I have a NSWindow containing 2 NSView, let's call them ViewA and ViewB.

ViewA has a list of subview objects, each object has its own tracking area set and handles a mouseDown event. ViewB is a hidden view, which appears above ViewA.

The problem is when ViewB appears, ViewA still receives mouseDown events. So when I click on ViewB, the object behind the ViewB receives the mouseDown event. I would like to know if there's any way to block the events of ViewA while ViewB is over it.

I know I can remove the tracking area from every object, but it still responds to the mouseDown event.

like image 794
QyoDeveloper Avatar asked Jan 13 '12 22:01

QyoDeveloper


1 Answers

You can override sendEvent: method on NSWindow and test 'firstResponder', if it is ViewA, than not call [super sendEvent:event] so ViewA will not receive any event.

like image 175
Bryan Chen Avatar answered Nov 02 '22 11:11

Bryan Chen