2 Replies
      Latest reply on Mar 27, 2020 2:57 AM by Scotty
      Scotty Level 1 Level 1 (0 points)

        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

        • Re: Detecting secondary mouse click
          Claude31 Level 8 Level 8 (9,135 points)

          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)

            • Re: Detecting secondary mouse click
              Scotty Level 1 Level 1 (0 points)

              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.