adds Clean Copy Support
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user