From dea535523950af294accc0f2b585c147b8dc8aba Mon Sep 17 00:00:00 2001 From: Jeon Suyeol Date: Mon, 21 Sep 2026 10:37:38 +0900 Subject: [PATCH] Fix popover closing right after it opens on macOS 27 The global mouse monitor watched both `.leftMouseUp` and `.leftMouseDown`. On macOS 27 the `.leftMouseUp` of the click that opens the popover is also delivered to that monitor, so `closePopover()` ran immediately after `openPopover()` and the popover flashed shut. Watching `.leftMouseDown` alone keeps outside-click dismissal intact, since a press outside already closes the popover before its release arrives. Fixes #96 --- Allkdic/AppDelegate.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Allkdic/AppDelegate.swift b/Allkdic/AppDelegate.swift index 86ed8d8..7c20149 100644 --- a/Allkdic/AppDelegate.swift +++ b/Allkdic/AppDelegate.swift @@ -55,7 +55,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { } private func setupEventMonitor() { - self.eventMonitor = NSEvent.addGlobalMonitorForEvents(matching: [.leftMouseUp, .leftMouseDown]) { [weak self] _ in + // Watch only `.leftMouseDown`: on macOS 27 the `.leftMouseUp` of the very click that opens the + // popover reaches this global monitor, which closed the popover right after it appeared (#96). + // A press outside is enough to dismiss, so the release never needed to be observed. + self.eventMonitor = NSEvent.addGlobalMonitorForEvents(matching: .leftMouseDown) { [weak self] _ in self?.closePopover() } NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in