TestButtonDown
This program displays an integer counter which increments (via an NSTimer) every 1/5 of a second. There is a Button labeled "Push Me and Hold". If you press and release this button, the counter will be reset to zero. But the whole point of this program is to show that it is possible to have an NSTimer be effective even while the button is held down. To see this, do as the button says - press it and hold the mouse button down. You will see that the counter keeps on incrementing whether the button is held down or not.
download the TestButtonDown project files
(Requires the Apple Developer Tools - I used the August 2002 release)
This project illustrates a few aspects of programming for Mac OS X using the Cocoa API:
- regular display updates via NSTimer
- using NSEventTrackingRunLoopMode to get timer events while mouse is down