View Full Version : Calling function when window comes to front?

Madd the Sane
Nov 25, 2011, 09:19 PM
What function should my NSWindowController subclass overload so that when the window controller is told to bring the window to the front, it calls functions? I use windowDidLoad, but if the window is closed, then brought back up, it doesn't get called.

Nov 26, 2011, 05:16 AM
Take a look at the NSWindowDelegate protocol: http://developer.apple.com/library/mac/#documentation/cocoa/reference/NSWindowDelegate_Protocol/Reference/Reference.html

The window will tell your delegate when it becomes the Key or Main window, which should be what you are after. You can make the window controller the delegate too, using [[self window] setDelegate:self];