Screenshots, hung out to dry. A tiny native macOS app that hangs every screenshot on a line at the top of your screen.
Swift
Double click opens a photo without copying it
Alejandro Buján512398bcfbda
diff --git a/Sources/Tendedero/GrabArea.swift b/Sources/Tendedero/GrabArea.swiftindex ccc90b2..7d17f74 100644--- a/Sources/Tendedero/GrabArea.swift+++ b/Sources/Tendedero/GrabArea.swift@@ -9,7 +9,8 @@ import SwiftUI/// - The Trash discards it./// - Nowhere that accepts it: the photo flies back to the line.///-/// Click copies, press and hold opens Markup, the corner cross discards.+/// Click copies, double click opens, press and hold opens Markup, the corner+/// cross discards.struct GrabArea: NSViewRepresentable {let item: Peggedlet line: Line@@ -98,6 +99,9 @@ final class GrabView: NSView, NSDraggingSource {private var startedDrag = falseprivate var holdTimer: Timer?private var didLongPress = false+ /// A click copies only once it is clear it is not the first half of a+ /// double click, which opens the photo and must leave the clipboard alone.+ private var clickTimer: Timer?/// How long you hold before Markup opens. Long enough not to fire on a/// slow click, short enough to feel deliberate.@@ -117,6 +121,10 @@ final class GrabView: NSView, NSDraggingSource {}override func mouseDown(with event: NSEvent) {+ if event.clickCount > 1 {+ clickTimer?.invalidate()+ clickTimer = nil+ }if isInCross(event) {downPoint = nilonDiscard()@@ -175,7 +183,21 @@ final class GrabView: NSView, NSDraggingSource {override func mouseUp(with event: NSEvent) {endPress()- if downPoint != nil && !startedDrag && !didLongPress && event.clickCount == 1 { onClick() }+ if downPoint != nil && !startedDrag && !didLongPress && event.clickCount == 1 {+ // Waits as long as the system lets a second click count as a double click.+ clickTimer?.invalidate()+ // The copy goes ahead even if the line redraws this view meanwhile.+ let copy = onClick+ let timer = Timer(timeInterval: NSEvent.doubleClickInterval, repeats: false) { [weak self] _ in+ MainActor.assumeIsolated {+ self?.clickTimer = nil+ copy()+ }+ }+ // Keeps time while a menu or a drag runs the loop in another mode.+ RunLoop.main.add(timer, forMode: .common)+ clickTimer = timer+ }downPoint = nildidLongPress = false}