• 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: Opening a closed window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Opening a closed window (From: "z" <email@hidden>)
 >Re: Opening a closed window (From: "Stephen Deken" <email@hidden>)

  • Prev by Date: Re: Opening a closed window
  • Next by Date: Re: Better printed documentation? (wish list)
  • Previous by thread: Re: Opening a closed window
  • Next by thread: Serious bug subclassing NSTextStorage
  • Index(es):
    • Date
    • Thread