Getting hold of a Documents Window for displaying a Sheet
Getting hold of a Documents Window for displaying a Sheet
- Subject: Getting hold of a Documents Window for displaying a Sheet
- From: Kevin Bracey <email@hidden>
- Date: Tue, 27 Apr 2004 13:22:19 +1200
Thanks Scott,
From: Scott Anguish <email@hidden>
Subject: Re: Getting hold of a Documents Window for displaying a Sheet
Date: Mon, 26 Apr 2004 19:45:38 -0400
To: Kevin Bracey <email@hidden>
It's hard to tell from this what is what. you're making a new
InfoController (which is a window controller for the sheet maybe? this
is what is hard to tell).
Yes, it is a InfoController : NSWindowController and has a separate
NIB. I was trying to do the [NSApp beginSheet/] sheet from this object,
but had the same problem with it not "conecting" to the front most
window, so then moved the code into the NSDocument object because I
hoped that I could get at the window object from there. I had the sheet
as a separate panel window but it would update the wrong window when
multi documents where open and it also confused the first tester. So I
hoped to move it to a sheet.
-(id) init
{
if( self = [super initWithWindowNibName:@"Information"])
{
// myWindow = [NSApp mainWindow];
// myDocument = [[myWindow windowController]document];
holdProperties = [[NSMutableDictionary dictionary] retain];
// [[self window] makeKeyAndOrderFront:self];
}
return self;
}
But if you make a new one and never set a window for it, you'll never
get a window value back from it.
I'm getting a sheet, the window from the nib is appearing but it's not
connected to the main front document window. It just appears in the
middle of the screen without a titlebar. And the whole Application goes
modal.
Do I need to connect this controller to a window?
You should just be able to get the windowControllers for the document
and (assuming you only have one) use the first one to get the window
and use that to attach the sheet to.
I have tried both [self windowForSheet] and [NSApp mainWindow] or
[[NSApp windows] objectAtIndex:0]] or [[[NSApp documents]
objectAtIndex:0] window] to build a link to the document window, as I
say for other messages like center the window responds but not for the
NSApp beginSheet.
When I put a debug point on the NSApp beginSheet, there is no self
_window. Which explains the symptoms but I can't see why, when it's
right there on the screen. Do I have to somehow link the Document to
it's window. Could it be that I haven't saved this document and then it
will understand that it has a window?
Thanks for your help,
This should be so easy, I feel duh! I want to use sheets on document
windows a lot. I would love to understand just what is going wrong.
Any other ideas?
On Apr 26, 2004, at 7:04 PM, Kevin Bracey wrote:
Hi all,
I've been battling this for a few days now and that means I'm doing
something wrong. There is very little in the way of comments
concerning this which also means I'm doing something the wrong way.
I'm trying to achieve this:
I have a document based App, each doc has additional properties, such
as header information which is not displayed in the main doc window.
I would like when selecting a menu Information for a sheet to pop down
and allow editing of this extra information, (just a MutDic)
I have achieved:
Setting up the menu and creating the delegate,
Getting the showInfo in the MyDocument, message to fire,
but for the life of me my document doesn't have a _window, I can see
it on the screen with my own two eyes, but when debugged there is no
_window, I can move it to with [[self windowForSheet] center], but
when used in the NSApp sheet command it's not there? So I get this
nice sheet popping out of nowhere.
this is in MyDocument
myInfo = [[[InfoController alloc] init] autorelease];
if( myInfo )
{
NSLog(@"I am in showPanel :%@", [myInfo description]);
NSLog(@"I am in self windowForSheet :%@", [self
windowForSheet]);
[NSApp beginSheet:[myInfo window]
modalForWindow:[self windowForSheet]
modalDelegate:self
didEndSelector:NULL
contextInfo:nil];
[NSApp runModalForWindow:[self windowForSheet]];
// Sheet is up here.
NSLog(@"does it come back here???");
[NSApp endSheet: [self windowForSheet]];
[[myInfo window] orderOut:nil];
}
2004-04-27 10:56:16.905 Lists[2801] I am in showPanel
:<InfoController: 0x39adc0>
2004-04-27 10:56:16.905 Lists[2801] I am in self windowForSheet
:<NSWindow: 0x34c960>
2004-04-27 10:56:23.181 Lists[2801] does it come back here???
I also have a close message connected to a button.
This has me totally puzzelled. Any hints as to where I'm going wrong?
Kind Regards
Kevin Bracey
"All palladium compounds should be regarded as highly toxic
and as carcinogenic." -- from a chemistry textbook
_______________________________________________
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.