views:

237

answers:

2

Hi Everyone:

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.

+2  A: 

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

Ahruman
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?
PF1
+1  A: 

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

Nicholas Riley
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?
PF1
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 <Carbon/Carbon.h>.
Nicholas Riley
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.
PF1
Add a fullscreen window behind yours (with the appropriate window levels) that intercepts the mouse clicks and does nothing with them.
Nicholas Riley
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.
PF1
It didn't work in 10.3, but should work on 10.4 and later.
Nicholas Riley
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 [...]
PF1
[...] 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.
PF1
You still need to use SetSystemUIMode.
Nicholas Riley
Kind of figured I was missing something... Then is there a way to pass SetSystemUIMode something in order to stop Expose?
PF1