Use a gesture recognizer to handle the double click

This commit is contained in:
Damiano Galassi committed 2026-09-22 16:29:42 +02:00
1 parent 17c7d67b96
commit 22c449f798
1 file changed
+5 -5
+5 -5
View File
@@ -283,6 +283,9 @@ final class ArtworkSelectorViewItem: NSCollectionViewItem {
override func viewDidLoad() {
super.viewDidLoad()
textField?.layer?.isOpaque = true
let recognizer = NSClickGestureRecognizer(target: self, action: #selector(handleGesture))
recognizer.numberOfClicksRequired = 2
self.view.addGestureRecognizer(recognizer)
}
private func updateLabels() {
@@ -344,12 +347,9 @@ final class ArtworkSelectorViewItem: NSCollectionViewItem {
// MARK: Actions
// FIXME
override func mouseUp(with event: NSEvent) {
if event.clickCount > 1, let action = doubleAction {
@objc func handleGesture() {
if let action = doubleAction {
target?.performSelector(onMainThread: action, with: nil, waitUntilDone: true)
} else {
super.mouseUp(with: event)
}
}