On Jun 7, 2010, at 2:58 PM, Jens Alfke wrote:

> On Jun 7, 2010, at 3:31 AM, Ken Thomases wrote:
> 
>> Why do you need such a notification?  Windows don't "spontaneously" become 
>> visible unbeknownst to your code.
> 
> I’ve run into this in an app that has a singleton panel, which I want to 
> persistently remember whether it’s open or closed. In other words, I want to 
> update a boolean user-default when the window opens or closes. But the panel 
> is in the main nib, with the “Show Panel" menu command simply wired up to its 
> -makeKeyAndOrderFront: method. So the window was indeed becoming 
> spontaneously visible without my code being called.
> 
> I found it was possible to detect closing via a notification, but not 
> opening. I ended up writing a custom -showMyPanel: method, wiring the menu to 
> that, and having that method set the default. Not a big deal, but it would 
> have been cleaner if there’d just been a window-did-become-visible 
> notification to listen to.

Hmm.  You can bind the window's 'visible' binding to some property on a 
controller (or even NSUserDefaultsController).  If it's bound to your own 
controller, then I guess that would give you a sort of notification when the 
visibility changes.

Still, I prefer the second approach you ended up taking.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to