From f9e7de718d1911d7c46db2bbeedfadaff48fd4b5 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 11 Nov 2023 12:43:02 -0600 Subject: [PATCH 1/3] Update right click toolbar code for Sonoma --- Mac/MainWindow/MainWindow.swift | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Mac/MainWindow/MainWindow.swift b/Mac/MainWindow/MainWindow.swift index 18409f76a..2035a1ff0 100644 --- a/Mac/MainWindow/MainWindow.swift +++ b/Mac/MainWindow/MainWindow.swift @@ -14,23 +14,34 @@ import Foundation // Since the Toolbar intercepts right clicks we need to stop it from doing that here // so that the ArticleExtractorButton can receive right click events. - if event.isRightClick, - let frameView = contentView?.superview, - let view = frameView.hitTest(frameView.convert(event.locationInWindow, from: nil)), - type(of: view).description() == "NSToolbarView" { + if #available(macOS 14.0, *) { + if event.isRightClick, + let frameView = contentView?.superview, + let view = frameView.hitTest(frameView.convert(event.locationInWindow, from: nil)), + let articleExtractorButton = view as? ArticleExtractorButton { - for subview in view.subviews { - for subsubview in subview.subviews { - let candidateView = subsubview.hitTest(subsubview.convert(event.locationInWindow, from: nil)) - if candidateView is ArticleExtractorButton { - candidateView?.rightMouseDown(with: event) - return + articleExtractorButton.rightMouseDown(with: event) + return + } + } else { + if event.isRightClick, + let frameView = contentView?.superview, + let view = frameView.hitTest(frameView.convert(event.locationInWindow, from: nil)), + type(of: view).description() == "NSToolbarView" { + + for subview in view.subviews { + for subsubview in subview.subviews { + let candidateView = subsubview.hitTest(subsubview.convert(event.locationInWindow, from: nil)) + if candidateView is ArticleExtractorButton { + candidateView?.rightMouseDown(with: event) + return + } } } + } + super.sendEvent(event) } - - super.sendEvent(event) } } From 96dd6cea16cf4337aadb2fe7f1c7fcffc8c44e11 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 11 Nov 2023 12:53:12 -0600 Subject: [PATCH 2/3] Fix regression that didn't allow any events to register --- Mac/MainWindow/MainWindow.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mac/MainWindow/MainWindow.swift b/Mac/MainWindow/MainWindow.swift index 2035a1ff0..9390a8f7f 100644 --- a/Mac/MainWindow/MainWindow.swift +++ b/Mac/MainWindow/MainWindow.swift @@ -41,7 +41,9 @@ import Foundation } - super.sendEvent(event) } + + super.sendEvent(event) } } +s From c0f11ea91ac50143c98605cd424cf9855bb8b7c2 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 11 Nov 2023 12:57:10 -0600 Subject: [PATCH 3/3] Remove extraneous character --- Mac/MainWindow/MainWindow.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Mac/MainWindow/MainWindow.swift b/Mac/MainWindow/MainWindow.swift index 9390a8f7f..6dd8abf8f 100644 --- a/Mac/MainWindow/MainWindow.swift +++ b/Mac/MainWindow/MainWindow.swift @@ -46,4 +46,3 @@ import Foundation super.sendEvent(event) } } -s