1

I am creating a fullscreen app and am wondering if there is some way to make NSAlert go above the CGDisplayCapture that I created. Right now, the NSAlert is displaying behind the display capture. My main window is displaying just fine (after adjusting it with setLevel:) but NSAlert doesn't seem to be working as well. I attempted to do:

[[alertBox window] setLevel:CGShieldingWindowLevel()];

But that doesn't seem to work either. I imagine that there must be some way to do this, but I am just not sure where to start.

Any help would be appreciated.

individualtermite
  • 3,615
  • 16
  • 49
  • 78

2 Answers2

2

There is no supported way to display a window when the display is captured. That’s what capturing the display means.

Jens Ayton
  • 14,532
  • 3
  • 33
  • 47
  • Hi Ahruman: Okay, I kind of get that. So, is there any supported way to get a "screen" behind my window so that the user can't change apps, use Spotlight, etc? – individualtermite Jul 31 '09 at 23:10
1

If you want to display a multiwindowed UI but prohibit app switching, etc., use SetSystemUIMode instead of CGDisplayCapture.

Nicholas Riley
  • 43,532
  • 6
  • 101
  • 124
  • Nice find Nicholas! However, I am having a bit of trouble passing SetSystemUIMode the various attributes. Do I have to include another library besides Cocoa for this to work? – individualtermite Aug 01 '09 at 02:47
  • Yes, SetSystemUIMode and its constants are present in HIToolbox.framework (a subframework of Carbon.framework). There's no problem using it if your app has a Cocoa UI; you just need to #include . – Nicholas Riley Aug 01 '09 at 06:11
  • That makes more sense now. :) Anyway, after importing the Carbon framework, the code now works fine. However, I am running into a bit of a problem that I don't think the class was created for. That problem is that I cannot disable the user from clicking on other windows (which "over rides" my code). Is there some way to make this not happen, despite the documentation saying "Note disabling the Dock using this technique will only disable the Dock long as the calling application is frontmost."? Thanks for your help. – individualtermite Aug 01 '09 at 15:35
  • Add a fullscreen window behind yours (with the appropriate window levels) that intercepts the mouse clicks and does nothing with them. – Nicholas Riley Aug 01 '09 at 19:54
  • Thanks for your suggestion Nicholas. While I don't have the code in front of me, will this also stop the user from using Expose to switch windows? I am trying to recreate the display capture effect, except that the method you suggested will allow multiple windows (main window, NSAlert, etc) and that's what would work best. Thanks for your help. – individualtermite Aug 03 '09 at 16:34
  • I am running into a bit of problems with the background window. My code is: NSRect screenRect; screenRect = [[NSScreen mainScreen] frame]; NSWindow *backgroundWindow = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:[NSScreen mainScreen]]; [backgroundWindow makeKeyAndOrderFront:nil]; [backgroundWindow setFrame:screenRect display:YES]; However, this doesn't seem to disable Exposure. Is there [...] – individualtermite Aug 03 '09 at 21:02
  • [...] something I'm missing (and is there some way to make the main window stay in front of the other window forever)? Thanks for all your help. – individualtermite Aug 03 '09 at 21:03
  • You still need to use SetSystemUIMode. – Nicholas Riley Aug 03 '09 at 22:24
  • Kind of figured I was missing something... Then is there a way to pass SetSystemUIMode something in order to stop Expose? – individualtermite Aug 05 '09 at 17:57