Re: Panels shared by documents
Re: Panels shared by documents
- Subject: Re: Panels shared by documents
- From: Matt Neuburg <email@hidden>
- Date: Mon, 24 Jun 2002 11:10:41 -0700
On Fri, 21 Jun 2002 17:18:50 -0400, Itrat Khan <email@hidden> said:
>
>
On Friday, June 21, 2002, at 02:44 PM, Matt Neuburg wrote:
>
>
>
> How's that going to help? The panel's windowDidUpdate: delegate method
>
> will
>
> be called when the panel updates. But that's not what Brent needs to
>
> know;
>
> he needs to know when a different main document becomes active.
>
>
Every window is told to update on each pass of the event loop. When a
>
document window becomes active, the panel will be told to update on the
>
next iteration of the loop, where you can then update the panel's
>
outlets based on the active document.
Aha. (Sound effect: lightbulb switches on.) Wow, good answer! The docs do
actually say this ("An NSWindow is automatically sent an update message on
every pass through the event loop") but I would still never have thought of
using this fact in the way you suggest, i.e. as sort of periodic event for
checking the state of things.
My only worry would be the wastefulness and time consumption of running
this code every single time thru the event loop. Obviously that is far
better than a true periodic event, timer, or whatever, but still, the only
time we *need* to be called (in this example) is when there is actually a
change in what doc window is active. My usual rule of thumb is to let the
app framework make the decisions for us wherever possible, rather than
checking a condition often in code. That's exactly what using the
NSWindowDidBecomeMainNotification does. But I take it you don't find this
to be a real concern?
Thx again -
m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
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.