2

As far as I know, sheets modal for a certain window without "freezing" the app can only be NSSavePanels, NSOpenPanels, and NSAlerts windows (since NSAlert isn't a NSWindow or NSPanel subclass but it has an associated window); if I wanted a generic NSPanel to be such a sheet, for example, I couldn't prevent it from freezing the app since the only (?) way to start that sheet is using

[NSApp beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]

So, is there any way to set a generic panel as a sheet without freezing the entire app?

user732274
  • 1,069
  • 1
  • 12
  • 28
  • It's not clear what you're trying to do here. Are you wanting the `NSPanel` to be completely non-modal? – gaige Jun 16 '13 at 18:39
  • I want it to be a sheet (= attached to another window) without freezing the app – user732274 Jun 16 '13 at 18:40
  • 2
    You've already found the way to do that, use `-[beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]`. What's not working for you? – gaige Jun 16 '13 at 18:42
  • The app gets frozen doing so: it waits for the sheet to be closed. – user732274 Jun 16 '13 at 18:43
  • How many windows do you have open? The sheet will prevent doing anything else in that window, but if you have second window open in the app, it should operate just fine. – gaige Jun 16 '13 at 18:44
  • Two windows: if I start that sheet modal for one of them, I cannot interact with the other window until the sheet is closed. – user732274 Jun 16 '13 at 18:45
  • That's strange, it should work. – gaige Jun 16 '13 at 18:52
  • From NSApp's docs: "While the application is in the run loop, it does not respond to any other events (including mouse, keyboard, or window-close events) unless they are associated with the sheet." – user732274 Jun 16 '13 at 18:53
  • Badly phrased documentation. I am staring at code here which has been working since 2008 and we use this in a dozen different places for window-modal presentations. – gaige Jun 16 '13 at 18:55
  • [Sheet conceptual docs](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Sheets/Concepts/AboutSheets.html#//apple_ref/doc/uid/20001043-BABFIBIA). Are you using separate documents for each? If not, maybe it's seeing the documents as the same and handling it as document-modal. – gaige Jun 16 '13 at 18:57
  • For clarity, our sheets are based on `NSPanel`, so you shouldn't have a problem because of the `NSWindow` type. – gaige Jun 16 '13 at 19:04
  • My fault: there still was a [NSApp runModalForWindow:] around. – user732274 Jun 16 '13 at 19:12
  • That'd explain it ;-) – gaige Jun 16 '13 at 19:16

1 Answers1

0

-[beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:] for you with an NSPanel without difficulty.

However, if you have multiple windows on the same document, NSApp will block all windows within that document, since it's actually Document modal, not Window modal.

gaige
  • 17,263
  • 6
  • 57
  • 68