Catching NSSlider -mouseUp: events (workaround)
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