MenuActionDismissBehaviour .disabled "unavailable" Xcode 15.2

Hi,

Within my app, I am building a menu and don't want it to close with every click. When you click start, I want the menu to remain open etc. I have searched the documentation and this seems like exactly what I want. I am still very new to Swift so potentially making a silly mistake.

MenuActionDimissBehaviour

I have decided to play with just example code from the documentation and use within my ContextView file.

import SwiftUI

struct ContentView: View {
    @State private var count = 0
    var body: some View {
        VStack {
            
            Menu("Font size") {
                Button(action: {count += 1}) {
                    Label("Increase", systemImage: "plus.magnifyingglass")
                }
                .menuActionDismissBehavior(.disabled)
                
                
                Button("Reset", action: {count = 0})
                
                
                Button(action: {count -= 1}) {
                    Label("Decrease", systemImage: "minus.magnifyingglass")
                }
                .menuActionDismissBehavior(.disabled)
            }
            
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

Xcode keeps saying "disabled" is unavailable in MacOS. I am a bit confused as the documentation says it can work from MacOS 13.3+. I am using the latest OS, latest Xcode etc.

Very confused. Any help would be greatly appreciated.

Thanks in advance

The disabled enum isn't available under macos. The other enums list it. https://developer.apple.com/documentation/swiftui/menuactiondismissbehavior/disabled

@jlilest ah ok thankyou! I missed that. Do you know any other ways of implementing the functionality I am after? Getting that kind of more fine-grain control. I am building a menu bar application and it’s just a bit inconvenient having to keep reopening the menu after clicking an action. Thanks in advance :)

Yes, as jlilest states, disabled isn't available on macOS for whatever reason. You are correct that MenuActionDismissBehavior is available on macOS 13.3+, but the dismiss behaviour disabled is not supported on macOS: https://developer.apple.com/documentation/swiftui/menuactiondismissbehavior/disabled

[@Matt Cox](https://developer.apple.com/forums/profile/Matt Cox) Thank you for your reply! I missed that. Do you know any other ways of implementing the functionality I am after? Getting that kind of more fine-grain control. I am building a menu bar application and it’s just a bit inconvenient having to keep reopening the menu after clicking an action. Thanks in advance :)

MenuActionDismissBehaviour .disabled "unavailable" Xcode 15.2
 
 
Q