Search code examples
objective-cmacoslockscreen

"Lock" Screen On Mac App


In Mac OS X, what API do I need to call in order to place a window over not only the entire screen, but the menu bar and dock as well? Also, is it possible to effectively "lock" the screen into this position, disabling Mission Control, launchpad, etc.?

I have tried the following code within the App Delegate's implementation file:

- (void)awakeFromNib {
    @try {
        NSApplicationPresentationOptions options = NSApplicationPresentationDisableForceQuit + NSApplicationPresentationDisableHideApplication + NSApplicationPresentationDisableProcessSwitching + NSApplicationPresentationHideDock + NSApplicationPresentationHideMenuBar + NSApplicationPresentationFullScreen;
        [NSApp setPresentationOptions:options];
        NSLog(@"Set presentation options"); 

    }
    @catch (NSException *exception) {
        NSLog(@"Error. Invalid options");
    }

}

NSLog reads "Set presentation options", but nothing else happens. Any tips?


Solution

  • This would basically involve the same sorts of thing as "kiosk mode". See Apple's Kiosk Mode Programming Topic.

    You basically use -[NSApplication setPresentationOptions:] or -[NSView enterFullScreenMode:withOptions:] with an option dictionary containing the key NSFullScreenModeApplicationPresentationOptions whose value is an NSNumber containing the same sort of presentation option values as the NSApplication method takes.