Skip navigation.
 
mlRe: Multiple movable modals
FROM : Zach Wily
DATE : Tue Jun 14 15:58:04 2005

Andy,

You can try something like this:

        [currentModalWindow addChildWindow:newModalWindow 
ordered:NSWindowAbove];
        [NSApp runModalForWindow:newModalWindow];
        // Modal window runs here
        [currentModalWindow removeChildWindow:newModalWindow];
        [newModalWindow orderOut:self];

I've done that before to have a modal window on top of another modal 
window, and it worked fine if I remember correctly.

zach


On Jun 14, 2005, at 6:46 AM, Andy Bettis wrote:

> Hello again,
>
> In my app I want to display a moveable modal dialog. (Please take 
> my word that I have good reasons for doing this.) I have subclassed 
> NSWindowController to control the dialog, with an init method:
>
> - (id)init
> {
>    self = [super initWithWindowNibName:@"CCategoriesDialog"];
>    return(self);
> }
>
> I use a class method to start the dialog up:
>
> + (id)create:(MyDocument*) inDocument
> {
>    CCategoriesDialog* theDialog = [[CCategoriesDialog alloc] init];
>
>    [theDialog setDocument:inDocument];
>
>    [[theDialog window] setLevel:NSModalPanelWindowLevel];
>
>    [NSApp runModalForWindow:[theDialog window]];
>
>    [theDialog showWindow:self];
>
>    return(theDialog);
> }
>
> And I have a 'go away' method:
>
> - (IBAction)OK:(id)sender
> {
>    [NSApp stopModal];
>
>    [self autorelease];
> }
>
> So far, all is well. Should I be doing anything else to tidy up 
> when the panel goes away?
>
> Unfortunately I want to spawn a second modal dialog from this one. 
> When I do so it looks fine but the new window is not modal, it is 
> possible to click and select the first one, which is not what I 
> want. I imagine that I need to call [NSApp stopModal] on the first 
> window before calling [NSApp runModalForWindow:[theDialog window]] 
> on the second one - is this true? If so I need to know when the 
> second one has gone away so I can restore the [NSApp 
> runModalForWindow:[theDialog window]] call on the first window 
> again. What I would like to do is to put the NSApp modal on/off 
> calls in methods that are called when the window becomes or stops 
> being the key window but I can't work out where this should be. Do 
> I need to use notifications for this?
>
> Also, is it possible to set the window level in IB?
>
> Thanks in advance,
>
> Rev. Andy
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
mlMultiple movable modals Andy Bettis Jun 14, 14:46
mlRe: Multiple movable modals Zach Wily Jun 14, 15:58
mlRe: Multiple movable modals Eric Brunstad Jun 15, 02:04