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

goyalpk

macrumors newbie
Original poster
Aug 7, 2009
14
0
Hi Guys I am trying to display a custom modal dialogue box and am doing it the following way:

EncPasswordSheet is of IBOutlet NSWindow * type.

@implementation EncryptionPasswordSheet

-(id)init { return self; }

(void)showCustomDlg: (NSWindow *)window { if (!EncPasswordSheet) {

[NSBundle loadNibNamed: @"EncryptionPasswordDlg" owner: self];
}

[NSApp beginSheet:EncPasswordSheet modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil]; [NSApp runModalForWindow: EncPasswordSheet];

[NSApp endSheet: EncPasswordSheet]; [EncPasswordSheet orderOut: self];

}

(IBAction)getPasswordFromSheet: (id)sender {

password = [passwordField stringValue];
[NSApp stopModal]; }

(IBAction)cancelEncPasswordSheet: (id)sender {

password = nil; [NSApp stopModal];

}

@end

The problem is that the dialogue box is getting displayed well and its taking input and on pressing ok or cancel, their respt IBAction methods are getting executed and program is continuing to execute except with one problem: the dialogue box is not getting out of the way i.e its not getting clsed or dissappearing. Please tell where i am going wrong.

Thanks
 
Don't use beginSheet and runModal together. They should be used separately. If you don't understand this go read up on modal windows and sheets at developer.apple.com
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.