Re: very specialized event handling
Re: very specialized event handling
- Subject: Re: very specialized event handling
- From: "Louis C. Sacha" <email@hidden>
- Date: Fri, 27 Feb 2004 21:30:06 -0800
Hello...
If the problem is that the windowDidMove method is called repeatedly
when the window is being moved and not just once when it is done
moving, this might be a good candidate for the NSObject method
performSelector:withObject:afterDelay: method.
/* not tested, typed in email, etc... */
- (void)windowDidMove:(NSNotification *)note
{
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(windowMightFinishMoving) object:nil];
[self performSelector:@selector(windowMightFinishMoving)
withObject:nil afterDelay:0.1];
}
- (void)windowMightFinishMoving
{
if ([[NSApp currentEvent] type] != NSLeftMouseDragged)
{
/* do your task here... */
}
}
This assumes that the current event will always be a mouse dragged
event until the user lets go of the mouse button, but I don't know
whether or not that is the case, so you'll need to test it (I can't
at the moment).
If it works, you would probably also want to adjust the
NSTimeInterval used for the delay, to the point where it is quick
enough that a user can't take another action after moving the window
before it fires, but not so quick that it is constantly firing off
the selector and is having an effect on performance.
You could do the same sort of thing with windowDidResize: if you need
to do a task when the window is finished resizing (I wasn't sure from
your message if you need to trigger the task with windowDidMove:,
windowDidResize:, or both).
Hope that helps,
Louis
I'm doing a particular task during NSWindowController:windowDidMove.
I've noticed, however, that whenever this method is called, the
NSApp:currentEvent is a mouse dragged event. It's never a mouse up
event. This is a problem because I'd like to do the particular task
after the user releases the mouse button. So, I'm looking for
another event handler. The next one that comes to mind is, of
course, NSWindow:mouseUp. Unfortunately, that method gets called
neither during nor after resizing the window. Presumably, this event
is gobbled up by the mechanism that does the window resizing. I've
looked around for other alternatives but am stumped. Any suggestions?
email@hidden
_______________________________________________
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.
_______________________________________________
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.