• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
"Modal Session Requires Modal Window" Error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"Modal Session Requires Modal Window" Error


  • Subject: "Modal Session Requires Modal Window" Error
  • From: Simone Manganelli <email@hidden>
  • Date: Mon, 21 Jun 2004 14:30:04 -0700

I have two random questions about Cocoa development. First, I'm trying to implement a portable class that contains two sheets; these sheets will attach to any window that supports a certain method that I implement. The thing is that I can't attach the same sheet to multiple windows, so I created a class based on a separate nib file, which I can use simply by instantiating the custom class to get a new set of sheets to use on the windows that need it.

The only problem seems to be that when I try to activate one of the sheets inside this nib file on a window that's not in the nib file, I get a "Modal session requires modal window" exception. Does that mean that I can only attach a sheet to a window in the same nib file as the sheet? And if so, how do I get around my original problem -- i.e.: how should I create sheets so that I can attach them to any window that needs it, without running into the limitation where any one sheet can only be attached to one window? (Let me know if this whole question makes sense.)

I've done some digging on this error message, and it seems that it usually happens when the window pointer to which the sheet attaches to is nil. But I'm positive that my pointer is not nil, because I explicitly pass a window that is currently visible when I call this code snippet:

- (void)killProcessWithName:(NSString *)name PID:(int)thePID attachingSheetToWindow:(NSWindow *)theWindow
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Don't Show Kill Confirmation"]) {
[self killWithoutConfirmation:thePID];
} else {
[killSheetString setStringValue:[NSString stringWithFormat:NSLocalizedString(@"KillConfirm",nil),name]];
[NSApp beginSheet:killSheet modalForWindow:theWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:[NSNumber numberWithInt:thePID]];
}
}

I've done some testing, with logging the window object using NSLog, and even testing the validity of the passed theWindow object by making it visible, and it all seems to indicate that the theWindow object is valid, not nil as the error would suggest. I'm kind of stumped here.



Also, I was also wondering if there's a way to get which window contains a toolbar item that was clicked, since it sends the toolbar item as the sender to the method that responds to the click. I've got a bunch of different windows that have the same toolbar, and there doesn't seem to be a way to differentiate between a toolbar button click in one window from another, given that they're all synchronized since they use the same toolbar identifier. I've looked through the methods implemented by NSToolbarItem and NSToolbar, but none of them seem to be able to give me the window that contains the toolbar or toolbar item.

Any help would be much appreciated. Thanks.

-- Simone Manganelli
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: "Modal Session Requires Modal Window" Error
      • From: "Louis C. Sacha" <email@hidden>
  • Prev by Date: Re: Value Transformers and MVC ...
  • Next by Date: Re: Dynamic User Interface with Cocoa
  • Previous by thread: Rép : NSArrayController
  • Next by thread: Re: "Modal Session Requires Modal Window" Error
  • Index(es):
    • Date
    • Thread