Re: Catching NSSlider -mouseUp: events (workaround)
Re: Catching NSSlider -mouseUp: events (workaround)
- Subject: Re: Catching NSSlider -mouseUp: events (workaround)
- From: Uli Kusterer <email@hidden>
- Date: Wed, 11 Apr 2007 11:56:07 +0200
Am 11.04.2007 um 05:05 schrieb Roland Torres:
- (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 ...
}
It might be safer (as in, not confusing anything in the event
system that might expect mouse events to be balanced), if you just
directly called whatever method you want to trigger instead of
synthesizing a mouse event. E.g.:
- (void)mouseDown:(NSEvent *)event
{
[super mouseDown:event]; // eats the mouse-up event
if( [[self target] respondsToSelector: mouseUpSelector] )
[[self target] performSelector: mouseUpSelector withObject:
self];
}
where mouseUpSelector would be an instance variable of type SEL, not
unlike the action in target/action.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
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