3

I have tried the following block in the app delegate's applicationDidStart function:

let mainScreen = NSScreen.screens[0]
window.contentView?.enterFullScreenMode(mainScreen, withOptions: nil)

This is fine, however once the app starts and enters full screen mode, there is no way to get out of it. Escape key, force quit, command q, nothing works. The only way is literally a force reboot. In mac os big sur, force reboot will open the app again in full screen mode.

This is not behaviour I want. I tried adding an onExitCommand { } block using a solution to access the NSWindow instance from within a swiftUI view (link below), but this hangs the app.

How to access own window within SwiftUI view?

I thought this would be a no nonsense and straight forward solution, but it appears to be more convoluted than expected.

Anyone have a solution?

Thanks

1 Answer 1

1

I encountered the same issue; using the toggleFullScreen method worked for me.

NSApplication.shared.windows.first?.toggleFullScreen(nil)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.