How to get rid of Enter Full Screen menu item?
Asked Answered
M

3

4

In my Mac OS X app I deleted all default menu items, added my own.

But in View menu at the bottom I can still see Enter Full Screen menu item, whilst in storyboard there is no such menu item.

I've tried to delete the entire View menu, but now it migrated to Window menu. Even though it's disabled, I would still like to get rid of it entirely if possible.

Muskrat answered 3/9, 2018 at 18:53 Comment(1)
In your applicationDidLaunch: method, you can hunt down the menu item and remove it.Magallanes
G
7

The release notes for AppKit for 10.11 suggest you can use the NSUserDefault NSFullScreenMenuItemEverywhere.

Full Screen Menu Item

AppKit automatically creates an "Enter Full Screen" menu item after the application finishes launching if an equivalent menu item isn't found. If this menu item should not be created for your app, before NSApplicationDidFinishLaunchingNotification is sent you may set the NSFullScreenMenuItemEverywhere default to NO.

- (void)applicationWillFinishLaunching:(nonnull NSNotification *)notification {
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"];
}
Gratianna answered 4/9, 2018 at 3:8 Comment(0)
M
4

For Swift 4

func applicationWillFinishLaunching(_ notification: Notification) {
    UserDefaults.standard.set(false, forKey: "NSFullScreenMenuItemEverywhere")
}
Muskrat answered 4/9, 2018 at 17:50 Comment(0)
F
0

For SwiftUI

The "Enter Full Screen" menu item can still remain after the .commandsRemoved() Scene modifier is applied. In this case, "Enter Full Screen" case be removed with one of the following SwiftUI approaches:

Approach: UserDefaults

@main
struct MyApp: App {

  init() {
    UserDefaults.standard.set(false, forKey: "NSFullScreenMenuItemEverywhere")
  }

  var body: some Scene { … }
}

Approach: AppStorage property wrapper

@main
struct MyApp: App {
  @AppStorage("NSFullScreenMenuItemEverywhere")
  var fullScreenEnabled = false

  init() {
         fullScreenEnabled = false
  }

  var body: some Scene { … }
}

Answered here: How can I disable and even remove the option of EnterFullScreen in View menu in macOS in SwiftUI?

Footlocker answered 12/5, 2023 at 0:37 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.