1

My NSPanel window is always on top of all other apps windows. This is how I load it:

[NSApp beginSheet:[self window] modalForWindow:[rootDocument mainWindow] modalDelegate:self didEndSelector:nil contextInfo:nil];

I've tried to change the level with setLevel: and different level types, or using orderBack: or orderFront: . But it seems these methods have no effect, since the window is always on top.

thanks

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
aneuryzm
  • 63,052
  • 100
  • 273
  • 488

1 Answers1

1

You do not pass nil, Nil, 0, or NULL to didEndSelector. Ever. You pass a selector to a method (-sheetDidClose:returnCode:contextInfo:) that you have declared. That you are passing something other than a selector makes whatever else you're doing to dismiss the sheet suspect. (You haven't said if the panel stays on top because it's never dismissed, but that's my assumption here.)

Take a look at Using Custom Sheets, which is Apple's own documentation on the subject.

Also, be sure that the panel you are using has its "Visible At Launch" flag turned off in IB.

Extra Savoir-Faire
  • 6,026
  • 4
  • 29
  • 47
  • No, the panel is correctly dismissed when the operation is done. But during the operation the panel stays on top of all apps, that's why I specified that I tried to use orderBack and orderFront – aneuryzm Feb 12 '13 at 11:44
  • You shouldn't have to resort to fiddling with the z-order of the panel. When you call `-beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:`, your sheet is behaving modally, which means it *should* be on top, but only on top of the window to which it's attached (i.e., document-modal). When your sheet is active, it *is* attached to a window, right? – Extra Savoir-Faire Feb 13 '13 at 00:16
  • No it is not attached to the window, it is just showing itself on top of it. I know that a modal window should be on top of my app window but not all other apps windows. – aneuryzm Feb 19 '13 at 08:40
  • We're talking about a sheet. Sheets are *supposed* to be attached to their "host" window, and should slide down from that window's title bar. That your sheet is not doing this, but is on top of "other apps windows" tells me that its panel is not set up correctly. There is a flag for a window or panel in Interface Builder, `Visible At Launch`. You need to be certain that this is turned off. If you do this, your sheet should behave correctly. – Extra Savoir-Faire Feb 19 '13 at 22:49