PDA

View Full Version : getting nsview to do something on right and middle click




Chirone
Nov 11, 2010, 07:34 PM
this may or may not be simple

i want to know when the user has right or middle clicked on a view.

you'd think it be as easy as just overriding the -(void)rightMouseDown: method... but it doesn't trigger... :confused:

i thought maybe i have to make - (void)acceptsFirstMouse: return YES, but that method is never called

i even tried overriding the - (NSMenu*)menuForEvent: and + (NSMenu*)defaultMenu methods but those never get called either.

and yes, the view is at the top and it is the first responder. It responds to mouseDown: and it's set up to respond to mouseMoved:

what am I missing?



kainjow
Nov 11, 2010, 07:56 PM
Post your code.

I made a new empty project, rightMouseDown: and mouseDown: get called just fine with no extra code.

What OS?

Chirone
Nov 11, 2010, 08:16 PM
i made an empty project as well and i could right click and pick up the event

makes me wonder what happened in the bigger project.

in the bigger project the view is a subview of a view that's inside a clipview of a scrollview.

upon further experiments i've found that the view that should be receiving right clicks will indeed receive them but only if i don't add the two subviews that are sitting on it.

However, this doesn't make much sense to me as it receives mouseDown events easily and the two subviews don't even cover the entire view that is meant to receive right clicks.

the two little subviews also have no code that passes on the mouse events to their super view...

gnasher729
Nov 12, 2010, 05:45 PM
i made an empty project as well and i could right click and pick up the event

makes me wonder what happened in the bigger project.

in the bigger project the view is a subview of a view that's inside a clipview of a scrollview.

upon further experiments i've found that the view that should be receiving right clicks will indeed receive them but only if i don't add the two subviews that are sitting on it.

However, this doesn't make much sense to me as it receives mouseDown events easily and the two subviews don't even cover the entire view that is meant to receive right clicks.

the two little subviews also have no code that passes on the mouse events to their super view...


Right mouse clicks only go to the topmost view and are not passed along the responder chain.

Chirone
Nov 12, 2010, 05:53 PM
oh right. makes sense then..