8

When a popover shows, I'm curious whether it's possible to set the underlying settings on the popover's window, such as the window level. In my testing, popovers seem to be a window, but they doesn't respond to normal NSWindow selectors, such as setLevel:.

Is it possible to set the window level on a NSPopover?

sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161

1 Answers1

14

NSPopover is a subclass of NSObject, not NSWindow, so setting the window level is not officially supported.

You could try getting the window like this:

NSWindow* popoverWindow = yourPopover.contentViewController.view.window;

I have no idea whether you can then successfully set the level though.

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
  • Great work! Accessing the view's window just slipped my mind. Thanks. – sudo rm -rf Apr 03 '12 at 03:50
  • it's worth noting that you can get the window this way but not with [NSApp mainWindow] – valexa Nov 09 '12 at 04:51
  • 2
    You can certainly adjust the level of the window this way. But the window isn't instantiated until the popover has actually been displayed. I make such configurations each time I display the popover as I am unclear on the persistence of the supporting window. – ctpenrose Jul 30 '13 at 17:31