user2414590
user2414590

Reputation: 123

cocoa sheet is not modal

I can't figure out why the sheet is not modal and the focus is still on the main window.

- (IBAction) showSheet:(NSWindow*)window

{ // User has asked to see the dialog. Display it.

    if (!_clientsDialog)
        [NSBundle loadNibNamed: @"clientsDialog" owner: self];
        [NSApp beginSheet:self.clientsDialog
           modalForWindow: [[NSApp delegate]window]
            modalDelegate: self
           didEndSelector: NULL
              contextInfo: NULL];

}

Upvotes: 2

Views: 764

Answers (1)

d00dle
d00dle

Reputation: 1316

The following method works for me:

Header File:

- (IBAction)showSheet:(id)sender;

Method file:

- (void)showSheet:(id)sender {

    if (! _clientsDialog)
        [NSBundle loadNibNamed: @"clientsDialog" owner: self];

    [NSApp beginSheet: _clientsDialog
       modalForWindow: [[NSApp delegate] window]
        modalDelegate: self
        didEndSelector: NULL
            contextInfo: NULL];
}

IMPORTANT: You need to have a Title Bar on your window. Otherwise Controls won't work.

enter image description here

Upvotes: 4

Related Questions