I am trying to make the application startup in a presentation mode while disabling the Dock, Menubar, Processes Switching, etc. I have this code so far:
let presOptions: NSApplicationPresentationOptions =
.HideDock | // Dock is entirely unavailable. Spotlight menu is disabled.
// .AutoHideMenuBar | // Menu Bar appears when moused to.
// .DisableAppleMenu | // All Apple menu items are disabled.
.DisableProcessSwitching | // Cmd+Tab UI is disabled. All Exposé functionality is also disabled.
.DisableForceQuit | // Cmd+Opt+Esc panel is disabled.
.DisableSessionTermination | // PowerKey panel and Restart/Shut Down/Log Out are disabled.
.DisableHideApplication | // Application "Hide" menu item is disabled.
// .AutoHideToolbar |
.FullScreen
let optionsDictionary = [NSFullScreenModeApplicationPresentationOptions: presOptions]
browserWindowController.containerView.enterFullScreenMode(NSScreen.mainScreen()!, withOptions: optionsDictionary)
On the .HideDock line I get the error:
Type of expression is ambiguous without more context
Could somebody help me find a solution for that and explain what the error means.
Also on the browserWindowController line I get the error:
Use of unresolved identifier 'browserWindowController'
Could somebody explain to me why this isn't working?
With Swift 2 NSApplicationPresentationOptions
has to be an array:
let presOptions: NSApplicationPresentationOptions = [
.HideDock, // Dock is entirely unavailable. Spotlight menu is disabled.
// .AutoHideMenuBar, // Menu Bar appears when moused to.
// .DisableAppleMenu, // All Apple menu items are disabled.
.DisableProcessSwitching, // Cmd+Tab UI is disabled. All Exposé functionality is also disabled.
.DisableForceQuit, // Cmd+Opt+Esc panel is disabled.
.DisableSessionTermination, // PowerKey panel and Restart/Shut Down/Log Out are disabled.
.DisableHideApplication, // Application "Hide" menu item is disabled.
// .AutoHideToolbar,
.FullScreen
]
As for the browserWindowController
error it simply means that the Swift compiler doesn't know what this variable is. It may have be defined outside the scope of its current usage or even not declared at all.
I have updated the code for swift 4.2. Check it out.
//Enter kiosk mode
func KisokMode(){
let presOptions: NSApplication.PresentationOptions = [
.hideDock, // Dock is entirely unavailable. Spotlight menu is disabled.
.autoHideMenuBar, // Menu Bar appears when moused to.
.disableAppleMenu, // All Apple menu items are disabled.
.disableProcessSwitching, // Cmd+Tab UI is disabled. All Exposé functionality is also disabled.
.disableForceQuit, // Cmd+Opt+Esc panel is disabled.
.disableSessionTermination, // PowerKey panel and Restart/Shut Down/Log Out are disabled.
.disableHideApplication, // Application "Hide" menu item is disabled.
.autoHideToolbar,
.fullScreen
]
let optionsDictionary = [NSView.FullScreenModeOptionKey.fullScreenModeApplicationPresentationOptions: presOptions]
TheWindowExample.contentView?.enterFullScreenMode(NSScreen.main!, withOptions: optionsDictionary)
}
TheWindowExample is the window in which you want to work with kiosk mode.