Detecting secondary mouse click

Just playing with the new mouse/trackpad support and trying to detect both primary and seconday mouse button clicks.


I can detect them (primary OR secondary clicks) by setting the buttonMaskRequired on a UITapGestureRecognizer to EITHER UIEventButtonMaskPrimary or UIEventButtonMaskSecondary


BUT if I attempt to recognise both (buttonMaskRequired = UIEventButtonMaskPrimary | UIEventButtonMaskSecondary) then the gesture recogniser doesn't fire (for mouse clicks.)


Anyone know if this is an 'oversight' or I'm doing something wrong?


Thanks

Can you show the code where you set the mask ?


Usually, is is an OptionSet, so assigned such as [UIEventButtonMaskPrimary, UIEventButtonMaskSecondary] (that not's the exact names)

old school Objecive C


gesture.buttonMaskRequired = (UIEventButtonMaskPrimary | UIEventButtonMaskSecondary);


I have since made progress - but it feels real hacky.


Create 2 tap gesture recognisers - one with primary mask set, and the other with secondary mask set. I then kill the secondary gesture in the gestureRecognizerShouldBegin: delegate call if the UITouch type is UITouchTypeDirect so as to stop use getting 2 tap events with a finger.

Detecting secondary mouse click
 
 
Q