Re: State based on front most document (was RE: Documentation frustrations)
Re: State based on front most document (was RE: Documentation frustrations)
- Subject: Re: State based on front most document (was RE: Documentation frustrations)
- From: Matt Neuburg <email@hidden>
- Date: Mon, 11 Jul 2005 11:56:28 -0700
On Sun, 10 Jul 2005 22:27:22 -0400, Erik Buck <email@hidden>
said:
>Use the responder chain.
>
>The responder chain is a critical design pattern in Cocoa and one of
>the great strengths of Cocoa. Automatic menu validation (and much
>more) works based on the responder chain. Maintaining the state of a
>tool bar can/should also work based on the responder chain.
>
>One implementation is to override -update in the subclass of NSPanel
>that contains the tool bar or use the NSWindowDidUpdateNotification.
>
>"- (void)update
>
>Updates the window. The default implementation of this method does
>nothing more than post an NSWindowDidUpdateNotification to the
>default notification center. A subclass can override this method to
>perform specialized operations, but should send an update message to
>super just before returning. For example, the NSMenu class implements
>this method to disable and enable menu commands.
>An NSWindow is automatically sent an update message on every pass
>through the event loop and before it‚s displayed onscreen. You can
>manually cause an update message to be sent to all visible NSWindows
>through NSApplication‚s updateWindows method.
>See Also: ˆ setWindowsNeedUpdate: (NSApplication), ˆ updateWindows
>(NSApplication) http://developer.apple.com/documentation/Cocoa/
>Conceptual/WinPanel/Concepts/HowWindowIsDisplayed.html"
Going back to the previous topic for a moment, this is an excellent example
of what's wrong with the docs. "update" (with the corresponding
notification) is a great way to keep interface coordinated, enabling and
disabling interface items as the user clicks here or there. But the docs
don't explain this; I would never in a million years have thought of this
myself. The way I know it is because someone (maybe Erik) told me years ago.
It's the difference between a descriptive and a generative grammar: the docs
tell you in technical terms what "update" does, but they do not tell you
what you would use it for.
A good way to revise the docs would be to read over the archives for the
past several years. Repeated questions reveal very clearly the practical
tasks that people need to perform and can't figure out how. Those are the
very things that need better documentation. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
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