Specifications
Apple II Technical Notes
Apple IIGS
6 of 6 #71: DA Tips and Techniques
New Desk Accessory Tips and Techniques
An NDA Can Find its Menu Item ID
After the application has called FixAppleMenu, an NDA can look at its menu item template
(after the “\H” in the NDA header) to determine the menu ID corresponding to the NDA’s name
in the Apple menu. This is sometimes useful to pass to OpenNDA (if the NDA has some way to
open itself), or to pass to a Menu Manager call.
Finding the menu item ID in the NDA’s header is easy if the NDA is written in assembly. In a
high-level language it may be harder (if you don’t have direct access to your NDA’s header, you
need to find it on the fly and scan for the “\H”).
NDAs and Command- Keystrokes
To give the user a consistent way to close NDA windows, System 6.0 handles Command-W
automatically when a system window is in front. It calls CloseNDAbyWinPtr without letting
the NDA or the application see the Command-W.
However, there is a special action code (optionalCloseAction) that an NDA can accept to
handle the Close request itself. This way the NDA can offer the user a chance to cancel the
Close, which is impossible when the system calls the NDA’s main Close routine, as
CloseNDAByWinPtr does. (See the System 6.0 Toolbox documentation for details.)
There is no way for an NDA to accept some keystrokes and pass others along to applications, but
if your NDA does not want any keystroke events, turn off the corresponding eventMask bits in
the NDA header (this allows the application to receive keystrokes while your NDA window is in
front).
Calling InstallNDA From Within an NDA
It is possible to write an NDA that installs other NDAs. However, with System Software 5.0 and
later, InstallNDA returns an error when called from an NDA. When your NDA has control
because the Desk Manager called one of your NDA’s entry points, the Desk Manager’s data
structures are already in use, so InstallNDA is unable to modify them.
The solution is to use SchAddTask in the Scheduler to postpone the InstallNDA call until
the system is not busy. Remember that the Bank and Direct Page registers are not defined when
your scheduled task is executed.
Processing mouseUp Events
When an NDA’s action routine receives a mouseUp event, it is not always safe for the NDA to
draw in its window.
For example, when the user drags an NDA window, the NDA receives the mouseUp before the
window is actually moved, and before DragWindow erases the outline of the new window










