From f66cf57fa85623a1e9a900ed31b77e9a2049439a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20C=C3=A9sar=20Neves=20Enumo?= Date: Sun, 1 Aug 2021 16:08:34 -0300 Subject: [PATCH] Activate app on mouse hover (#52) --- Calendr/Events/EventView.swift | 4 +--- Calendr/Main/MainViewController.swift | 9 +++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Calendr/Events/EventView.swift b/Calendr/Events/EventView.swift index b8f12baa..8d9f2f6e 100644 --- a/Calendr/Events/EventView.swift +++ b/Calendr/Events/EventView.swift @@ -204,9 +204,7 @@ class EventView: NSView { popover.show(relativeTo: .zero, of: view, preferredEdge: .minX) return popover.rx.deallocated } - .bind(with: self) { view, _ in - view.window?.makeKey() - } + .subscribe() .disposed(by: disposeBag) } diff --git a/Calendr/Main/MainViewController.swift b/Calendr/Main/MainViewController.swift index 740d5bb2..1788538b 100644 --- a/Calendr/Main/MainViewController.swift +++ b/Calendr/Main/MainViewController.swift @@ -400,6 +400,15 @@ class MainViewController: NSViewController { statusBarButton.sendAction(on: .leftMouseDown) } + override func mouseEntered(with event: NSEvent) { + + super.mouseEntered(with: event) + + guard !NSApp.isActive else { return } + + NSApp.activate(ignoringOtherApps: true) + } + // MARK: - Factories private func styleButton(_ button: NSButton) {