Re: Opening a closed window
Re: Opening a closed window
- Subject: Re: Opening a closed window
- From: Shawn Erickson <email@hidden>
- Date: Mon, 13 Nov 2006 09:00:46 -0800
On Nov 13, 2006, at 8:57 AM, Stephen Deken wrote:
On 11/13/06, z <email@hidden> wrote:
- (BOOL)applicationShouldHandleReopen: (NSApplication *)
theApplication hasVisibleWindows: (BOOL)flag {
[ [NSApp mainWindow] makeKeyAndOrderFront: nil];
return YES;
}
By definition, a closed window cannot be main. An application's main
window is the window that has the focus -- which is usually also the
key window and the front window, but this does not have to be the
case. You will find that your [NSApp mainWindow] call returns nil if
the window has been closed.
Since your MyWindowController instance is your app's delegate, and (I
presume) that window controller has its -window outlet connected to
the window you want to display, try this:
-(BOOL) applicationShouldHandleReopen:(NSApplication*)theApp
hasVisibleWindows:(BOOL)v
{
[[self window] makeKeyAndOrderFront:nil];
return YES;
}
Also make sure you don't have your window set to release on close.
You can set that in code or in interface builder. IIRC the default
for IB defined window is to not release on close while for code
generated windows it is.
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden