3

i have an NSScrollView with an NSView set as its document view. I am trying to get the mousedown event in the NSScrollView but the NSView keeps intercepting it. Is there a way of stopping this from happening?

Also is there a way of stopping it in one area of the view much like an NSTrackingArea does for mouseentered.

Thanks in advance,

Ben

BenJacob
  • 957
  • 10
  • 31

1 Answers1

4

Can you override -mouseDown: in your subview to just forward the event to the next responder?

You can also this by overriding the superview's -hitTest: to return either itself (when you don't want subviews to receive events) or a subview (in all other cases where a subview contains the event location).

As regards your last question, you can accomplish this with -hitTest: as well. Just return self if the event occurs in a subview's "exclusion zone."

If you go this route, be sure to pay attention to the coordinate system in use at any given time and convert between them as needed.

Conrad Shultz
  • 8,748
  • 2
  • 31
  • 33
  • Sorry to return to this but is there any way of getting the normal behaviour if the mousedown location is outside the bounds you specify? i.e. returning whichever view would normally be returned? – BenJacob Apr 02 '12 at 12:03
  • I used the `-hitTest:` method in the way you suggested – BenJacob Apr 03 '12 at 17:51
  • Did you try `[super hitTest:...]`? I haven't tested it, but I would assume that the frameworks would pick things up and do the normal recursive hit testing. – Conrad Shultz Apr 03 '12 at 23:39