-
-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description, Steps to Reproduce, Crash Logs, Screenshots, etc.
This is my app code:
struct MyApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
MenuBarExtra {
MainView().environmentObject(appDelegate.handler)
} label: {
Image("tray-no-permissions-dark")
}
.menuBarExtraAccess(
isPresented: Binding(
get: { appDelegate.handler.isMenuOpen },
set: { appDelegate.handler.isMenuOpen = $0 }
)
) { statusItem in
appDelegate.statusItem = statusItem
}
.menuBarExtraStyle(.window)
}
This is my handler:
class callbackHandler: ObservableObject {
@Published var isMenuOpen: Bool = false
}
Then in my AppDelegate I want to open the menu programmatically after 15 seconds like so:
func applicationDidFinishLaunching(_ notification: Notification) {
DispatchQueue.main.asyncAfter(deadline: .now() + 15) {
self.handler.isMenuOpen = true
}
}
However, nothing happens. I can use the statusItem to performClick but I thought the binding would work. What am I missing?
Also, there are parts in my app that would need to open the menu programmatically, but that would make this boolean stay true even if the user doesn't dismiss the view. Wouldn't that be an issue? Is there a way to "trigger" the opening once?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working