Re: Accessing window in NSAlert didEndSelector:
Re: Accessing window in NSAlert didEndSelector:
- Subject: Re: Accessing window in NSAlert didEndSelector:
- From: Alain Schartz <email@hidden>
- Date: Thu, 09 Aug 2007 08:20:02 -0700
Thanks for your help Jaime,
I'm a step further now - although my problem's not solved yet. So this is the current state of affairs :
I have a document-based application. A "connect to database" window (it's a panel, actually, controlled by a custom NSWindowController class) is displayed using a menu item. I have a username text field on this panel, and I check it's contents after my user clicks the OK button. If the text field is empty, I display a "blabla no username" alert sheet (I attached this to the aforementioned "connect to database" panel).
Now when the user dismisses this alert, the focus returns to the main document (i.e. the MyDocument-class window) and the "connect to database" panel is left grayed-out. What I would like it to do is to make the username text field (or at least the panel) reclaim the focus at this point.
Thanks to your input I tried passing [windowController window] as contextInfo in the didEndSelector: , this works - nslogging [window title] in the didEndSelector: displays the correct window title. But the [window makeKeyWindow] on my next line simply does nothing - and I don't understand why.
Oh and btw I did not fiddle with canBecomeKey/MainWindow, so they're still at their defaults...
Thanks in advance,
Alain
I
On Thursday, August 09, 2007, at 04:26PM, "Jaime Magiera" <email@hidden> wrote:
>
>Hi,
>
>contextInfo is just a (void *). So, you should be able to pass any
>data of any type. For example...
>
>[[NSApplication sharedApplication] beginSheet: aSheet
> modalForWindow: [self window]
> modalDelegate: self
> didEndSelector: @selector
>( sheetDidEnd:returnCode:contextInfo:)
> contextInfo: theWindow];
>
>
>
>- (void) sheetDidEnd: (NSPanel*) inSheet returnCode: (int) returnCode
>contextInfo: (NSWindow *) aWindow
>{
> NSLog(@"Your Window: %@", [aWindow title]);
>
>}
>
>However, maybe you can just get the window of the sheet from the
>NSPanel...
>
>
>- (void) sheetDidEnd: (NSPanel*) inSheet returnCode: (int) returnCode
>contextInfo: (NSWindow *) aWindow
>{
> NSLog(@"Your Window: %@", [[inSheet parentWindow] title]);
>
>}
>
>HTH,
>
>Jaime Magiera
>Sensory Research
>http://www.sensoryresearch.net
>
>
>
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden