Hokay, so I've got the window coming up and becoming key, the timer fires, that part of life is good.
The problem is now, how to kill the timer. If I do nothing, every time I re-open the window, I get another timer. That's expected when I think about it. So, I tried doing notifications, but I think I'm getting the timer reference wrong. Pertinent code below:
on homeTeamTimeOut_(sender)
--homeTimeOutHud's orderFront_(me)
homeTimeOutHud's makeKeyAndOrderFront_(me)
set my homeTimeOutTime to 0
tell current application's NSWorkspace to set theWorkspace to sharedWorkspace()
set notifCenter to theWorkspace's notificationCenter()
tell notifCenter to addObserver_selector_name_object_(me,"theWindowClosed:","NSWindowWillCloseNotification",homeTimeOutHud)
set theTimeOutTimer to my NSTimer's scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(1,me,"timeOutTimerFired:","",true)
end homeTeamTimeOut_
That SEEMS to work, in that it doesn't throw errors and the timer works.
Timer code:
on timeOutTimerFired_(theTimeOutTimer)
set my homeTimeOutTime to homeTimeOutTime + 1
end timeOutTimerFired_
Window closing code:
on theWindowClosed_(notif)
my theTimeOutTimer's invalidate() --tried with and without "my", no difference noted.
tell current application's NSWorkspace to set theWorkspace to sharedWorkspace()
set notifCenter to theWorkspace's notificationCenter()
tell notifCenter to removeObserver_name_object_(me,"NSWindowWillCloseNotification",homeTimeOutHud)
end theWindowClosed_
It's clearly not killing the timer, so I know I'm missing something basic, but no idear what.
-- "Try to look unimportant; they may be low on ammo." Infantry Journal.
|