Re: Notification for mouse-up on NSStepper
Re: Notification for mouse-up on NSStepper
- Subject: Re: Notification for mouse-up on NSStepper
- From: glenn andreas <email@hidden>
- Date: Fri, 7 Dec 2007 08:56:04 -0600
On Dec 7, 2007, at 4:41 AM, Alastair Houghton wrote:
On 6 Dec 2007, at 22:41, John Stiles wrote:
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?
FWIW, I can't think of one, and I've also had to write code
previously that relies on the system-provided classes using the
tracking-loop approach to mouse tracking.
I doubt Apple will change any class currently using a tracking-loop
to use three-method tracking, but it would be nice to have some
guarantee that any system-defined NSResponder subclass that
currently tracks the mouse this way will *always* track the mouse
this way, at least for applications built on currently shipping
systems.
It's a shame that there's no obvious way from code to distinguish
between the two cases (i.e. tracking loop versus three-method
approach).
You can do this:
- (void) mouseDown: (NSEvent *) event
{
[super mouseDown: event];
if ([[NSApp currentEvent] type] == NSLeftMouseUp) {
[self doSomethingAfterTracking];
}
}
- (void) mouseUp: (NSEvent *) event
{
[self doSomethingAfterTracking];
}
So if the super's mouseDown does the tracking loop, the current event
will be the mouse up (that stopped the tracking loop). If it doesn't,
then mouseUp will be called like normal.
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
_______________________________________________
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