Re: NSTableView setDoubleAction/NSControl setAction
Re: NSTableView setDoubleAction/NSControl setAction
- Subject: Re: NSTableView setDoubleAction/NSControl setAction
- From: Ondra Cada <email@hidden>
- Date: Wed, 7 Aug 2002 16:32:44 +0200
On Wednesday, August 7, 2002, at 12:29 , Gerben Wierda wrote:
You'll see a single line with a clickCount of 1 for a single click, and
two lines, first with a clickCount of 1, then a clickCount of 2 for a
double click.
OK. So I cannot handle a double-click without handling a single click
first and when I handle the single click I do not know that a second
click is coming. I find this rather a silly behaviour, after all, there
is information in the system available when two single clicks turn into a
double-click (mouse settings).
Do be reasonable: this *can* be done of course, *BUT* for the penalty of
waiting the double-click delay (which is by default quite long,
incidentally) before *any* single-click code is performed.
At least for majority of applications and users, this would be very bad
solution. OTOH, for your own code, you can easily overcome the problem:
just re-write your code this way:
-(void)singleClick:sender { ...your original code... } // not connected as
the action
-(IBAction)singleClickAction:sender { // THIS is connected to the single
click action
[self performSelector:@selector(singleClick:) withObject:sender
afterDelay:A_BIT_MORE_THAN_DOUBLECLICK_DELAY];
}
-(IBAction)doubleClickAction:sender { // connected to the double click
action
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(singleClick:) object:sender]y
... normal doubleclick code ...
}
Incidentally, whenever possible, double-click behaviour should be an
extension of single-click one anyway. If it is not, there should be *HARD*
reasons not to, for it is quite unintuitive.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.