Skip to content

Screenshots, hung out to dry. A tiny native macOS app that hangs every screenshot on a line at the top of your screen.

Swift

Keep the line down while a photo's menu is open

Alejandro Bujánc66ffd057cf6
diff --git a/Sources/Tendedero/AppDelegate.swift b/Sources/Tendedero/AppDelegate.swift
index df74707..9b150e6 100644
--- a/Sources/Tendedero/AppDelegate.swift
+++ b/Sources/Tendedero/AppDelegate.swift
@@ -517,7 +517,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
let inside = NSMouseInRect(mouse, zone, false)
if inside && pinned { pinned = false }
- let busy = pinned || GrabView.isDragging || line.pressedID != nil || now < peekUntil
+ let busy = pinned || GrabView.isDragging || GrabView.isShowingMenu
+ || line.pressedID != nil || now < peekUntil
if inside || busy {
awaySince = nil
} else {
diff --git a/Sources/Tendedero/GrabArea.swift b/Sources/Tendedero/GrabArea.swift
index 01a1693..ccc90b2 100644
--- a/Sources/Tendedero/GrabArea.swift
+++ b/Sources/Tendedero/GrabArea.swift
@@ -78,6 +78,8 @@ struct GrabArea: NSViewRepresentable {
final class GrabView: NSView, NSDraggingSource {
static var isDragging = false
+ /// A photo's menu is open. It reaches past the line, so the line waits.
+ static var isShowingMenu = false
var url: URL?
var dragImage: NSImage?
@@ -179,7 +181,10 @@ final class GrabView: NSView, NSDraggingSource {
}
override func rightMouseDown(with event: NSEvent) {
+ // The menu runs until it closes, and the line stays down meanwhile.
+ GrabView.isShowingMenu = true
NSMenu.popUpContextMenu(menuProvider(), with: event, for: self)
+ GrabView.isShowingMenu = false
}
// MARK: NSDraggingSource