Re: Panels shared by documents
Re: Panels shared by documents
- Subject: Re: Panels shared by documents
- From: Itrat Khan <email@hidden>
- Date: Thu, 20 Jun 2002 21:59:32 -0400
On Thursday, June 20, 2002, at 04:09 PM, Brent Gulanowski wrote:
What is the most effective mechanism for a panel associating itself
with the current active document? I suppose the app delegate/controller
could listen for window activation notifications, find the document for
the window, and make sure that the active panel(s) were showing the
right document's data. How does it find the right document? ... or ...
That's about right, but instead of listening to window activation
notifications, implement the panel's windowDidUpdate: delegate method,
query [NSApp mainWindow] to get the current document, and update the
panel's outlets based on the current state of your document. That's the
basic approach, and you'll have to tailor it to your particular
situation.
The idea of implementing windowDidUpdate: is that it allows document
changes to come from a variety of sources (AppleScript, a background
task, undo, etc.), not just user actions. The panel is sent a did-update
event on several occasions, such as when the mouse moves or the panel
window activates. As long as you don't do anything computationally
expensive during windowDidUpdate:, it's a relatively efficient approach.
Itrat.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.