adds Clean Copy Support

This commit is contained in:
2026-10-12 09:43:57 +02:00
parent 188e078055
commit 281f5465a6
28 changed files with 579 additions and 120 deletions
+14 -1
View File
@@ -4,7 +4,7 @@ import SwiftUI
/// The keys the overlays react to, from a text field or a bare key catcher.
enum OverlayKey: Equatable {
case up, down, commandUp, commandDown, commandLeft, commandRight, enter, escape
case commandP
case commandP, commandEnter
/// Maps the text system's commands back to the keys that produced them.
init?(selector: Selector) {
@@ -21,6 +21,19 @@ enum OverlayKey: Equatable {
}
}
/// ⌘P or ⌘↩ from a text view, which sees them as key equivalents before any key handling.
init?(equivalent event: NSEvent) {
let modifiers = event.modifierFlags.intersection([.command, .shift, .option, .control])
guard modifiers == .command else { return nil }
if event.keyCode == 36 || event.keyCode == 76 {
self = .commandEnter
} else if event.charactersIgnoringModifiers?.lowercased() == "p" {
self = .commandP
} else {
return nil
}
}
/// Maps a raw key event, for overlays without a text field.
init?(event: NSEvent) {
let command = event.modifierFlags.contains(.command)