• 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 won't show a second time.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window won't show a second time.


  • Subject: Re: Window won't show a second time.
  • From: Joakim Danielson <email@hidden>
  • Date: Mon, 31 May 2004 11:50:01 +0200

On 2004-05-31, at 04.31, matt neuburg wrote:

> On Sun, 30 May 2004 17:44:04 +0200, Joakim Danielson <email@hidden>
> said:
>> I have a number of methods to show different windows in a class called
>> AppController. An example:
>>
>> - (IBAction)showAdminTransactions:(id)sender {
>> if (_wcTransactions == nil) {
>> JDTransactionControl *ctrl = [[[JDTransactionControl alloc]
>> init]
>> autorelease];
>> _wcTransactions = [[NSWindowController alloc]
>> initWithWindowNibName:@"Transaction" owner:ctrl];
>> }
>> [_wcTransactions showWindow:self];
>> }
>>
>> where _wcTransactions is an instance variable and
>> JDTransactionControl
>> is the C in MVC for this gui. The method are targets of menu actions
>> in
>> my MainMenu.nib
>>
>> The problem is that if I open and close a window, it will not display
>> itself again if I choice the same menu item again. The method gets
>> called but the message [_wcTransactions showWindow:self] won't do
>> anything the second time.
>
> Is the window set to release when closed? If so, that would explain it
> -
> there's nothing to show.
>
No, it's not. When I inspected the release flag in IB I saw that the
flag "Visible at launch time" was set. When unchecking that, the
window is never shown. I must be doing something completely wrong here,
or I have just missed a tiny detail :-)

> (On a separate topic: it seems to me very odd that you're opening a
> nib with
> an owner which you immediately release. Surely you want the nib's
> owner to
> persist as long as the nib is in use? Or perhaps you are presuming that
> initWithWindowNibName:owner: retains the owner? I've never opened a
> nib with
> a window controller that was not itself also the nib's owner, so I've
> never
> explored the technique you're using.)
>
The first version of this method (and the others) looked like this:

- (IBAction)showAdminTransactionTypes:(id)sender {
if (_wcTransactionTypes == nil) {
_wcTransactionTypes = [[NSWindowController alloc]
initWithWindowNibName:@"AdminTransactionTypes"];
}
[_wcTransactionTypes showWindow:self];
}

and I had File's owner set to NSWindowController in IB. It worked just
as I wanted and the window was displayed more than once. The reason I
changed was that I needed to have an instance variable in a control
class that was the content of a NSObjectController so I had to set
File's owner to my control class.

Joakim
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Handling NSTextField keyboard events
  • Next by Date: Re: Code Guidelines
  • Previous by thread: Re: Window won't show a second time.
  • Next by thread: NSRulerView
  • Index(es):
    • Date
    • Thread