Re: Sheet in a non-document-based Application
Re: Sheet in a non-document-based Application
- Subject: Re: Sheet in a non-document-based Application
- From: Matt Neuburg <email@hidden>
- Date: Sun, 12 Mar 2006 11:13:09 -0800
- Thread-topic: Sheet in a non-document-based Application
On or about 3/12/06 10:35 AM, thus spake "Torsten Trautwein"
<email@hidden>:
> Maybe I don't get your point as I'm fairly new to Cocoa programming, but
> that part is straight out of the Apple Documentary
>
> http://developer.apple.com/documentation/Cocoa/Conceptual/Sheets/
> Tasks/UsingAppModalDialogs.html
>
> Regards,
> Torsten Trautwein
>
> On Mar 12, 2006, at 7:23 PM, Matt Neuburg wrote:
>
>> On Sun, 12 Mar 2006 18:25:11 +0100, Torsten Trautwein
>> <email@hidden> said:
>>>>> [NSApp beginSheet: mySheet
>>>>> modalForWindow: window
>>>>> modalDelegate: nil
>>>>> didEndSelector: nil
>>>>> contextInfo: nil];
>>>>> [NSApp runModalForWindow: mySheet];
>>
>> There's your problem, surely. Either you want a doc-modal sheet or an
>> app-modal separate window; you can't mix them like this. m.
Well, you're perfectly right. (But despite that document, an
application-modal sheet seems to me unconventional. Still, that can't be the
source of the problem. I apologize.)
Okay, I see the problem now. Here you say this:
> IBOutlet NSWindow *mainMenu;
> IBOutlet NSWindow *mySheet;
> if (!mySheet)
> [NSBundle loadNibNamed: @"MySheet" owner: self];
Where is mySheet coming from? Nowhere. In other words, I'm going to bet that
the trouble is that mySheet is nil.
That is perhaps because you are directly copying the example. Don't, because
you don't understand the context in which that example is imagined to
operate. Forget the secondary nib. Just have one nib. Don't do any
loadNibNamed. Just point mySheet as an outlet to an actual NSPanel in your
MainMenu.nib and you'll be fine. Let me know if you need me to send you an
example project.
(If you want me to, I can also send you a working example that *does* use a
secondary nib. Then you will see how, in the example, mySheet was supposed
to be hooked up when the secondary nib was loaded.)
By the way, your trouble here illustrates one of the downsides of Cocoa's
dynamism. There is no penalty for referring to mySheet even though it's nil,
but it comes back to bite you later with a mysterious error message. m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
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