• 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
Catching NSSlider -mouseUp: events (workaround)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Catching NSSlider -mouseUp: events (workaround)


  • Subject: Catching NSSlider -mouseUp: events (workaround)
  • From: Roland Torres <email@hidden>
  • Date: Tue, 10 Apr 2007 20:05:46 -0700

Searching the archives, I couldn't find a solution to this problem: Some controls (like NSSlider) have their own event loop established in -mouseDown:, with the net effect that the -mouseUp: event is caught and processed behind the scenes. The downside to this is that if you override -mouseUp: with your own method, it won't get invoked. Bummer if you want to key off of the mouseUp event to do something or stop something in progress.

So, for the archives, here's the workaround I came up with for my NSSlider subclass:

- (void)mouseDown:(NSEvent *)event
{
    [super mouseDown:event];   // eats the mouse-up event
    NSEvent upEvent=[NSEvent mouseEventWithType:NSLeftMouseUp ...
    [NSApp sendEvent:upEvent]; // dispatch mouse-up event
}

- (void)mouseUp:(NSEvent *)event
{
    [super mouseUp:event];
    // your code goes here ...
}


Roland

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Catching NSSlider -mouseUp: events (workaround)
      • From: Uli Kusterer <email@hidden>
  • Prev by Date: Re: Validating Image File Drag and Drops
  • Next by Date: Re: Bindings delay issues
  • Previous by thread: Re: Validating Image File Drag and Drops
  • Next by thread: Re: Catching NSSlider -mouseUp: events (workaround)
  • Index(es):
    • Date
    • Thread