on-internet
← Community

How do you make Mac menu items enable/disable based on the front window in SwiftUI?

Stack Overflow ·

I'm writing an app that has 3 different types of windows, plus a settings window. Some of the menu commands affect only one of the window types. In AppKit, you give your menu items a selector as an action, and a target of nil. The system then walks the responder chain looking for a responder that responds to that selector. If it finds one, it enables the menu item. If not, it disables the menu items. That's all you have to do.

Comments

Sign in or sign up to comment and upvote.

No comments yet.