From 3eecaa036d21ac6e5c07cf2defccc2e8381ff680 Mon Sep 17 00:00:00 2001 From: Jason Morley Date: Fri, 29 Mar 2024 10:31:29 -1000 Subject: [PATCH] fix: Ignore mouse clicks in non-focused windows (#98) --- Folders/Views/InteractiveCollectionView.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Folders/Views/InteractiveCollectionView.swift b/Folders/Views/InteractiveCollectionView.swift index 8b83523..d8ce0dc 100644 --- a/Folders/Views/InteractiveCollectionView.swift +++ b/Folders/Views/InteractiveCollectionView.swift @@ -78,6 +78,11 @@ class InteractiveCollectionView: NSCollectionView { override func mouseDown(with event: NSEvent) { + // Ignore events if we're not the key window. + guard (self.window?.isKeyWindow ?? false) else { + return + } + window?.makeFirstResponder(self) let position = self.convert(event.locationInWindow, from: nil) @@ -170,6 +175,12 @@ class InteractiveCollectionView: NSCollectionView { } override func mouseUp(with event: NSEvent) { + + // Ignore events if we're not the key window. + guard (self.window?.isKeyWindow ?? false) else { + return + } + super.mouseUp(with: event) // Handle double-click.