4

I'm in the process of writing a Mac (10.6 / 10.7) application that authenticates users against an Active Directory domain before allowing them access to the computer (I'm told I can't allow users to log on via traditional log on services). I have the authentication code in place, and am now trying to make this login window fullscreen and unable to close.

Apple's Kiosk Mode API (documentation here) seems like a great fit for this, and I've used it to bring the window fullscreen, disable the dock / menu bar / force quit, etc., all of which works fine. The problem I'm having is that I can't seem to prevent users from simply CMD+Q'ing out of the application.

There's no point in a kiosk mode application with limitations when a user can just quit out of it, so I'm assuming I'm missing something. Below is an example of what I'm doing:

NSApplicationPresentationOptions options = 
NSApplicationPresentationHideMenuBar|NSApplicationPresentationHideDock|
NSApplicationPresentationDisableHideApplication|
NSApplicationPresentationDisableProcessSwitching|
NSApplicationPresentationDisableAppleMenu| NSApplicationPresentationDisableForceQuit;

[NSApp setPresentationOptions:options];
[[_window contentView] enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];

Result: Full screen window, no menu bar, no dock, can't force quit and can't CMD+Tab away from the screen. CMD+Q still quits the application.

Blastfire
  • 43
  • 1
  • 4
  • https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/doc/uid/TP40008592-CH1-SW4 – Eelke Jul 11 '12 at 14:13
  • What did the trick @Blastfire? – Pavan Feb 07 '14 at 01:54
  • 1
    You should either edit your own question with the correct solution and accept it as correct. Or accept the correct one, that way other people can benefit from it – forcewill Jul 31 '14 at 12:58

1 Answers1

4

I'm guessing he found the same solution that I did, but since it isn't actually answered here I thought I'd detail it.

What you need to do is to implement the following NSApplicationDelegate method:

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender

And then return NSTerminateCancel here when your app is in Kiosk mode.

Christian A. Strømmen
  • 3,181
  • 2
  • 25
  • 46