Re: NSSlider: differentiating mouseDown, mouseUp, mouseDragged
Re: NSSlider: differentiating mouseDown, mouseUp, mouseDragged
- Subject: Re: NSSlider: differentiating mouseDown, mouseUp, mouseDragged
- From: Brian Webster <email@hidden>
- Date: Fri, 17 Jan 2003 11:24:09 -0600
On Friday, January 17, 2003, at 09:56 AM,
email@hidden wrote:
I've tried subclassing NSSlider and putting overrides like this in the
subclass:
- (void)mouseUp:(NSEvent *)theEvent;
- (void)mouseDown:(NSEvent *)theEvent;
- (void)mouseDragged:(NSEvent *)theEvent;
But only the mouseDown: method ever gets called, not the other ones.
The reason for this is that NSlider is doing its own mouse tracking
loop within the mouseDown: routine, rather than returning immediately
and getting further events passed down to it. So it's fetching the
events from the event queue itself using [NSApp
nextEventMatchingMask:...], which makes it a little difficult to tell
when the mouse up occurs.
One approach that might work would be to override mouseDown:, call
super's implementation for that, and then when it returns, set your
flag and send out an action yourself.
- (void)mouseDown:(NSEvent*)event
{
[super mouseDown:event];
isFinalAction = YES;
[NSApp sendAction:[self action] to:[self target] from:self];
isFinalAction = NO;
}
- (BOOL)isFinalAction
{
//Use this to determine whether it's the mouse up when the action is
sent
return isFinalAction;
}
This would mean one additional action message being sent out, since
NSSlider will still send one out on the mouse up event, but I think it
would work OK.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.