Re: Notification for mouse-up on NSStepper
Re: Notification for mouse-up on NSStepper
- Subject: Re: Notification for mouse-up on NSStepper
- From: "Ken Ferry" <email@hidden>
- Date: Fri, 7 Dec 2007 13:08:07 -0800
It's not super-likely that 'mouse up' is exactly what you're after.
Remember that the user can manipulate a stepper with the keyboard.
Mouse down will never be called in that case, and if you do anything
that specifically looks for a mouse up after receiving the action
message, you won't see it.
Is the issue that you have a cheap action that you want to do
continuously as the user manipulates the slider, and an expensive
action that you want to do when he is finished (e.g. low quality photo
resize followed by high quality resize)? For that, one possibility is
to handle it at the controller layer by doing the expensive action on
a delay, and always canceling and rescheduling when you receive an
additional request. This is typed in the browser, so it's probably
slightly wrong, but something like this:
- (void)takeActionSlightlyAsyncronously:(id)sender {
[self takeCheapAction];
[[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(takeExpensiveAction) object:nil];
[self performSelector:@selector(takeExpensiveAction)
withObject:nil afterDelay:timeout];
}
-Ken
On Dec 6, 2007 2:41 PM, John Stiles <email@hidden> wrote:
> I'd like to get notified when the user releases the mouse after
> interacting with an auto-repeating NSStepper, so I can update my UI
> appropriately.
>
> However, this is challenging. There are no built-in notifications or
> delegate methods. I tried subclassing NSStepper and overriding -mouseUp:
> but this method is never called.
>
> I suspect (but haven't yet tested) that NSStepper overrides -mouseDown:
> and runs its own event loop while the mouse button is down, and consumes
> the mouse-up event. If that's the case, then I could override
> -mouseDown:, call [super mouseDown:event] and then once it returns, I
> know the mouse has been released and the stepper has already gone
> through all of its motions. However, I am not sure that this is a safe
> thing to rely on; I hate to rely on implementation details that could be
> subject to change.
>
> Is there a good way to do this that I haven't thought of?
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please 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
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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