Mac Kiosk模式API-防止用户退出 [英] Mac Kiosk Mode API - Prevent Users from Quitting
问题描述
我正在编写一个Mac(10.6/10.7)应用程序,该应用程序在允许用户访问计算机之前先根据Active Directory域对用户进行身份验证(被告知我不允许用户通过传统方式登录登录服务).我已经设置了验证码,现在正尝试使该登录窗口全屏显示并且无法关闭.
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的Kiosk Mode API(此处的文档 )似乎非常适合此操作,并且我使用它来使窗口全屏显示,禁用停靠栏/菜单栏/强制退出等,所有这些都可以正常工作.我遇到的问题是,我似乎无法阻止用户仅将CMD + Q从应用程序中移出.
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];
结果:全屏窗口,没有菜单栏,没有停靠,无法强制退出,并且CMD + Tab不能离开屏幕. CMD + Q仍退出该应用程序.
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.
推荐答案
我猜他发现了与我相同的解决方案,但是由于这里没有实际回答,我想我会详细介绍.
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.
您需要做的是实现以下NSApplicationDelegate方法:
What you need to do is to implement the following NSApplicationDelegate method:
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
当您的应用处于信息亭模式时,然后在此处返回NSTerminateCancel.
And then return NSTerminateCancel here when your app is in Kiosk mode.
这篇关于Mac Kiosk模式API-防止用户退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!