Skip to content

Commit 930eebe

Browse files
authored
Merge pull request #420 from amirroid/fix/tray-menu-position-native-popup
fix(macos-tray): use native performClick for context menu to fix wrong popup position
2 parents b1c502a + 797e6a7 commit 930eebe

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/native/macos/tray.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ private class MenuDelegate: NSObject, NSMenuDelegate {
5151
guard let ctx = contexts[trayPtr] else { return }
5252

5353
if event.type == .rightMouseUp || event.modifierFlags.contains(.control) {
54-
if let menu = ctx.contextMenu {
54+
if let menu = ctx.statusItem.menu != nil ? ctx.statusItem.menu : ctx.contextMenu {
5555
ctx.menuOpenedCallback?(trayPtr)
56-
let menuLocation = NSPoint(
57-
x: sender.frame.minX,
58-
y: sender.frame.minY - 5
59-
)
60-
menu.popUp(positioning: nil, at: menuLocation, in: sender)
56+
ctx.statusItem.menu = menu
57+
sender.performClick(nil)
58+
ctx.statusItem.menu = nil
6159
}
6260
} else if event.type == .leftMouseUp {
6361
let callbackPtr = trayPtr.advanced(by: 24)

0 commit comments

Comments
 (0)