Yang-Xijie / InputSourceSwitcher

A menu bar app to swiftly change input sources using shortcuts on macOS Big Sur. [Swift+SwiftUI] NO LONGER MAINTAIN
MIT License
36 stars 6 forks source link

Dispositioned Popover #13

Open Yang-Xijie opened 3 years ago

Yang-Xijie commented 3 years ago
statusBarItem?.button?.action = #selector(AppDelegate.togglePopover(_:))
// When starting the app, show the popover. If don't do like this, open the app and shortcuts will not work until click the icon on the menu bar.
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
    if let button = self.statusBarItem?.button {
        self.popover.show(
            relativeTo: button.bounds,
            of: button, preferredEdge: NSRectEdge.minY)
    }
}

The problem is that if the user hide the menu bar (System Preferences -> Dock & Menu Bar -> Dock & Menu Bar -> Automatically hide and show the menu bar -> checked), the popover will appear on the top left corner of the screen, instead of appearing below the menu bar icon.

Also check https://github.com/zaferarican/menubarpopoverswiftui2/issues/3#issuecomment-894803220