Re: Setting the Key window after sheet ends
Re: Setting the Key window after sheet ends
- Subject: Re: Setting the Key window after sheet ends
- From: Allan Rentcome <email@hidden>
- Date: Sat, 17 Mar 2007 22:00:47 -0500
Well,
Firstly, the comments below and the code snippet are *not* mine but
posted by another kind list member.
However, sender in this case is a NSButton and I am not sure how this
would help me. Besides the NSbutton is part of the sheet not the
window I want to make key.
The code below is not quite correct since after the while loop the
parent object will set to nil after the allObjects message. However,
before this message I saved the window object in another id and used
that in the makeKeyAndOrderFront message. Other than that it worked
fine and I was grateful to the original poster.
Thanks for your helpful post though :-)
Allan
On Mar 17, 2007, at 4:20 PM, Kevin Bracey wrote:
It's Amazing you haven't checked (id)sender
Cheers
Kevin
Amazing that there actually is not method to get the window to which
a given sheet is attached. Or, at least, I didn't find one.
One way to do this (typed in Mail):
-(IBAction)endProductSelector:(id)sender
{
id parent;
NSEnumerator *windowsEnumerator = [[NSApp windows]
objectEnumerator];
//find the parent window
while(parent = [windowsEnumerator nextObject]){
if([parent attachedSheet] == [self window]){
[windowsEnumerator allObjects];
}
}
// close the window
[[self window] orderOut:sender];
// end the sheet
[NSApp endSheet:[self window] returnCode:1];
if(parent != nil){ //this test may not be necessary
[parent makeKeyAndOrderFront:self];
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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