Re: Re: NSSlider did finish sliding
Re: Re: NSSlider did finish sliding
- Subject: Re: Re: NSSlider did finish sliding
- From: "Bruce Johnson" <email@hidden>
- Date: Sat, 2 Sep 2006 10:14:32 -0700
Thanks, it was just what I needed.
Maybe you could give a small explanation as to the underlying machinery of:
[NSObject cancelPreviousPerformRequestsWithTarget: self selector: sel
object: sender];
I'm happy that it works, but what is it doing.
thanks
On 9/2/06, Michael Ash <email@hidden> wrote:
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
--
----
Bruce Johnson
email@hidden
_______________________________________________
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