Re: NSSlider did finish sliding
Re: NSSlider did finish sliding
- Subject: Re: NSSlider did finish sliding
- From: "Michael Ash" <email@hidden>
- Date: Sat, 2 Sep 2006 07:37:57 -0400
On 9/2/06, Bruce Johnson <email@hidden> wrote:
I need an NSSlider to operate on two levels.
1- to continuously update while it is being dragged (via the checkbox in IB)
2- to inform (via delegate or notification) that the user has finished
dragging the slider control (via mouseUp I'm guessing)
I've tried something simple (and obvious) like subclassing NSSlider
and over-riding the mouseDown and mouseUp methods of NSResponder. But
maybe I don't know enough about overriding events to get it to work.
I suspect something in the responder/event chain...
int the subclass of the slider:
- (void)mouseDown:(NSEvent *)theEvent
{
NSLog("@mouse down");
[super mouseDown: theEvent];
}
- (void) mouseUp: (NSEvent *)theEvent
{
NSLog("@mouse up");
[super mouseUp: theEvent];
}
I can't get the mouseUp log to print. What other hoops am I missing?
There is no need to subclass NSSlider to get this functionality.
Merely make your action method look like this:
- (void)sliderMoved: (id)sender {
SEL sel = @selector( sliderDone: );
[NSObject cancelPreviousPerformRequestsWithTarget: self selector:
sel object: sender];
[self performSelector: sel withObject: sender afterDelay: 0.0];
}
Because the runloop mode is different during event tracking, the
delayed perform doesn't happen until the mouse is released.
Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden