Triple-Click to override Double-Click..?

So in my app users can select a larger block of connected elements with a triple-click, just like selecting a paragraph works in an NSTextView.

However, a small subset of these elements also has properties that can be edited and a double-click switches to edit mode for these elements..

This leads to the current, unfortunate behaviour:

  • If a user triple-clicks a non-editable element the entire block of elements is highlighted, no problem.
  • If a user triple-clicks editable elements an edit is triggered and the third click is ignored.

What would be the best approach to enable triple-click on editable elements, i.e. something like waiting whether a third mouse click follows and enabling edit mode only then..?

Some dispatch after mechanism with a delay of NSEvent.doubleClickInterval maybe?

Any suggestions on how to implement this in a robust manner would be much appreciated!

Cheers,
Jay

Post not yet marked as solved Up vote post of JayMcBee Down vote post of JayMcBee
557 views

Replies

So you defined 2 gestures, for double and triple click ? Could you show the code ?

Then, use requireGestureRecognizerToFail as described here (objC for UIKit, but should be very easy to adapt):

https://stackoverflow.com/questions/20847594/uitapgesturerecognizer-detect-double-or-triple-tap

UITapGestureRecognizer *gestureRecognizerTripleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tripleTapDetected:)];
[gestureRecognizerTripleTap setNumberOfTapsRequired:3];
[self.theView addGestureRecognizer:gestureRecognizerTripleTap];

UITapGestureRecognizer *gestureRecognizerDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapDetected:)];
[gestureRecognizerDoubleTap requireGestureRecognizerToFail:gestureRecognizerTripleTap];
[gestureRecognizerDoubleTap setNumberOfTapsRequired:2];
[self.theView addGestureRecognizer:gestureRecognizerDoubleTap];
  • Sorry, but you've answered to a macOS/AppKit question ...

  • That's why I warned it was objC for UIKit… But using NSClickGestureRecognizer instead of UITapGestureRecognizer should not be too hard a change.

  • Nevermind, you don't seem to be familiar with macOS development.. ;-)

Add a Comment