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

Re: Catching NSSlider -mouseUp: events (workaround)


  • Subject: Re: Catching NSSlider -mouseUp: events (workaround)
  • From: Ron Fleckner <email@hidden>
  • Date: Fri, 13 Apr 2007 00:10:42 +1000


Roland Torres wrote:

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


Roland, even easier:

// in subclassed NSSlider
- (void)mouseDown:(NSEvent *)event
{
	// do your stuff here, then...
	[super mouseDown:event];

}

works for me.

Ron
_______________________________________________

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: Roland Torres <email@hidden>
  • Prev by Date: Re: Drawing to NSImage to create image data at different resolutions
  • Next by Date: Re: OSX equivalent of Registry Keys?
  • Previous by thread: Re: Catching NSSlider -mouseUp: events (workaround)
  • Next by thread: Re: Catching NSSlider -mouseUp: events (workaround)
  • Index(es):
    • Date
    • Thread