• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
mouse click events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: mouse click events
      • From: Pandaa <email@hidden>
  • Prev by Date: Re: Is there a regular expression class for Objective C?
  • Next by Date: Re: FTP Framework recommendation
  • Previous by thread: Re: Java version optimization
  • Next by thread: Re: mouse click events
  • Index(es):
    • Date
    • Thread