Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

satyam90

macrumors regular
Original poster
Jul 30, 2007
242
0
Bangalore, India
I have 2 NIB's "A" & "B". At different instances I need to show a Modal dialog(window or panel) from both the NIB's.
Currently I created one more NIB "C" with NSWindow object and showing from both NIB's using showWindow method. But when "C" is shown from "A" or "B", "C" is shown and normal processing is taking place in "A" & "B" and closing when it reaches that command. But I cant to stop "A" & "B" processing untill "C" is closed.
Is there any method or widget available to make my window modal.
 

satyam90

macrumors regular
Original poster
Jul 30, 2007
242
0
Bangalore, India
I have gone through the documentation that u specified.
I am showing the window first and then calling "runModalForWindow" with my window as parameter. Everytime, I have to do this to make it modal window.
I tried to put "runModalForWindow" at the end of windowDidLoad, and stopModal before closing the window. Here I observed that the window is shown, when I press cancel, it is closing and again it is showing, when I press cancel, it is closed.

Code:
static id instance = nil;
+(id) sharedInstance
{
    if(instance == nil)
    {
      instance = [[[self class]alloc]init];
    }
    return instance;
}

- (id) init
{
     if (self = [super initWithWindowNibName:@"MyWindName" owner:self])
     {
     }	
     return self;
}

-(void)windowDidLoad
{
     [B][NSApp runModalForWindow:[self window]];[/B]
}
.
.
.
.
.
.
.
- (IBAction) onCancel:(id)sender
{
      [NSApp stopModal];
      [[self window] close];
}

Can anyone tell me why it is getting called twice? Also I observed that "init" is also getting called twice. One instance is I am calling "init" is in createing the instance. When second time "init" is getting called?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.