mouse click events
mouse click events
- Subject: mouse click events
- From: "David Piasecki" <email@hidden>
- Date: Thu, 13 May 2004 17:36:24 -0700
How does one typically handle mouse click events? I'm trying to handle
the single and double click events separately. I found the
documentation describing how to handle mousedown events, and this works
great for dragging and single clicks. It says to use [event clickCount]
to figure out whether it's a single, double, or triple click, but
double+ clicks show up as a single click followed by the number of
clicks afterward. Maybe there's a simple solution to avoiding the first
click when a second has been clicked, but this is eluding me at the
moment. Here's what I've got so far...
- (void)mouseDown:(NSEvent *)event
{
BOOL keepOn = YES;
NSPoint mouseLoc;
while (keepOn) {
event = [[self window] nextEventMatchingMask: NSLeftMouseUpMask
|
NSLeftMouseDraggedMask];
mouseLoc = [self convertPoint:[event locationInWindow]
fromView:nil];
switch([event clickCount]) {
case 2:
printf("Double-click\n");
break;
case 1:
printf("Single-click\n");
break;
default:
break;
};
switch ([event type]) {
case NSLeftMouseDragged: // dragging
break;
case NSLeftMouseUp:
keepOn = NO;
break;
default:
/* Ignore any other kind of event. */
break;
}
};
return;
}
_______________________________________________
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.