• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Window OnVisible
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window OnVisible


  • Subject: Re: Window OnVisible
  • From: Sanjay Samani <email@hidden>
  • Date: Sat, 6 Oct 2007 08:34:08 +0100


Vance,

I think you can use some combination of -[NSWindow isVisible], - [NSWindow isKeyWindow] and -[NSApplication isActive] to determine if you are the foremost window, rather than add your own variable.

To control when the window is opened, in IB uncheck the "Visible at launch time" option for the Window in the inspector. Set a custom class for the File's Owner object in IB and then use :

BOOL loadedNib = [NSBundle loadNibNamed:@"<name of your nib, without extension" owner:<instance of your custom class, set as File's Owner in IB>];

or -[NSWindow makeKeyAndOrderFront] as appropriate for your needs.

You may also want to use the "Release when closed" option in IB, which will release the memory used by the Window and call the dealloc method if you have a custom NSWindow object. Note that this won't release the window controller, so may not be helpful to you.

Sanjay

vance wrote

Thanks, I am trying to do some memory intensive processing when the window shows up and then release all the memory when the window disappears (is closed)

Does that mean I have to keep track of the window state myself? (for example, before makeKeyAndOrderFront is called, I should set a variable bVisible = YES and set bVisible = NO on the NSWindowDidExposeNotification notification handler, and only run my code when there is a transition from NO to YES inside the NSWindowDidExposeNotification handler)

Also, is there an easy way for Interface Builder NOT to create an instance of this NSWindow class, and let me create the instance and set the outlet myself, on demand, when the window is needed. (that way I could put this code inside init)

I am new to cocoa and mac development so I am not very sure of the best way to implement this.

-Vance

On Oct 5, 2007, at 6:50 PM, Scott Thompson wrote:


On Oct 5, 2007, at 6:44 PM, vance wrote:

What method should I override, or to what notification should I subscribe to know when a window gets shown on the screen (goes from hidden to visible). In other words the opposite of NSWindowWillCloseNotification

Your best bet is probably NSWindowDidExposeNotification, but that notification may be called for other reasons as well.


Scott




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Prev by Date: What is Object Class Name used for in bindings?
  • Next by Date: QT & NSData
  • Previous by thread: Re: Window OnVisible
  • Next by thread: Cocoa to Tool application convertion
  • Index(es):
    • Date
    • Thread