2021年2月9日星期二

Beginner stuck with a problem with NSScreen.screens

Im a beginner with swift and Im learning as I go with a project for myself. Right now, Im trying to make a "kiosk mode" window appear that maximizes to fill the entire screen while the menu bar and dock are hidden so the app cant be exited (This for a procrastination app by the way). However, after getting everything working, Im having a problem as the space that was taken up by the menubar now has a gap that I need filled (see pic1). Because of this gap, the user is able to click the gap and exit the app which Im trying to prevent. I'd really appreciate any help I could get with this (my code is below the pic).

Note: Im working with Swift 4.1 and Xcode 9.4.1

import Cocoa    typealias NSRect = CGRect    class MainWindowController: NSWindowController {    convenience init() {    self.init(windowNibName: NSNib.Name(rawValue: "MainWindowController"))    }    override func windowDidLoad() {    super.windowDidLoad()    NSMenu.setMenuBarVisible(false)    NSApp.presentationOptions = [.hideDock, .hideMenuBar, .disableForceQuit, .disableProcessSwitching,.autoHideToolbar]    window?.backgroundColor = NSColor(red: 1, green: 0, blue: 0, alpha: 0.754)    window?.isOpaque = false    window?.setFrame(NSScreen.screens[0].frame, display: true, animate: false)    window?.styleMask.remove(.titled)    }    }  
https://stackoverflow.com/questions/66131197/beginner-stuck-with-a-problem-with-nsscreen-screens February 10, 2021 at 01:07PM

没有评论:

发表评论