Re: Accessing window in NSAlert didEndSelector:
Re: Accessing window in NSAlert didEndSelector:
- Subject: Re: Accessing window in NSAlert didEndSelector:
- From: Jaime Magiera <email@hidden>
- Date: Thu, 9 Aug 2007 10:26:34 -0400
Hi,
On Aug 9, 2007, at 8:44 AM, Alain Schartz wrote:
Hello list,
I have an alert sheet which is displayed if a text field on a
window is empty. The alert is displayed using
beginSheetModalForWindow: and calls a didEndSelector: method. But
after dismissing the alert, the focus seems to return to the main
DOCUMENT window and not to the TRIGGERING window of the alert (i.e.
the window onto which the alert was attached).
Is the calling window also a sheet of the document? I'm trying to
imagine how control would return to a completely separate window.
So in my didEndSelector: method I want to call makeWindowKey: to
return focus to my triggering window. Can anyone give me a hint how
this can be done? I suppose I should use contextInfo: to pass a
pointer to my window to the didEndSelector, but I can't seem to
find any valuable example in the documentation.
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