Re: NSTimer fires after invalidated - why?
Re: NSTimer fires after invalidated - why?
- Subject: Re: NSTimer fires after invalidated - why?
- From: Henry McGilton <email@hidden>
- Date: Wed, 22 Mar 2006 20:59:06 -0800
On Mar 22, 2006, at 8:19 PM, Walt Horat wrote:
If a particular drawer is concealed when the user types, we want to
open the
drawer and have it close after a period of time; each keystroke shall
reset
the timer.
The following code does not work, while to my understanding it should.
What
is wrong with my understanding?
-(void) keyDown: (NSEvent*) theEvent
{
...
...
if ([m_drawer state] != NSDrawerOpenState)
{
[ m_drawer open]; // open, if not already
[m_drawerCloseTimer invalidate]; // " Stops the receiver
from
// ever firing again and
// requests its removal
from its
// NSRunLoop"
[m_drawerCloseTimer release];
m_drawerCloseTimer = [[NSTimer scheduledTimerWithTimeInterval:
5.0
target: m_drawer
selector: @selector(close:)
userInfo: nil
repeats: NO] retain];
}
}
We start with a nil timer, so the first time through the invalidate and
release are no-ops.
We allocate a timer to fire 5 seconds in the future; the timer is wired
directly to the drawer close.
The actual behavior is that the drawer closes 5 seconds after the first
keypress, regardless of any keystrokes that occur in the interim.
Looks like the above block of code is executed only when the drawer
is closed.
Also you might wish to question the notion of having elements
of the interface jumping up and down in your face every time you
press a key . . . Think of 'Mister Paper Clip' on Windo$e. . .
Cheers,
........ Henry
===============================+============================
Henry McGilton, Boulevardier | Trilithon Software
Objective-C/Java Composer | Seroia Research
-------------------------------+----------------------------
mailto:email@hidden | http://www.trilithon.com
|
===============================+============================
_______________________________________________
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