+ // File
+
+ CommandGroup(after: CommandGroupPlacement.saveItem) {
+ Divider()
+ Button("Export...") {
+ if let selectedEvolution, let document {
+ if let image = document.exportAsImage(withEvolution: selectedEvolution) {
+
+ let filename = url?.deletingPathExtension().lastPathComponent ?? "Untitled"
+
+ let savePanel = NSSavePanel()
+ savePanel.allowedContentTypes = [.png]
+ savePanel.canCreateDirectories = true
+ savePanel.isExtensionHidden = false
+ savePanel.title = "Save \(filename) as image"
+ savePanel.message = "Choose a location to save the image"
+ savePanel.nameFieldStringValue = "\(filename).png"
+ savePanel.begin { result in
+ if result == .OK, let url = savePanel.url {
+ if let tiffRepresentation = image.tiffRepresentation {
+ let bitmapImage = NSBitmapImageRep(data: tiffRepresentation)
+ let pngData = bitmapImage?.representation(using: .png, properties: [:])
+ do {
+ try pngData?.write(to: url)
+ } catch {
+ return
+ }
+ }
+ }
+ }
+ }
+ }
+ }.keyboardShortcut(
+ "e", modifiers: EventModifiers([.command])
+ ).disabled(document == nil)
+ }
+
+ // Edit
+
+ CommandGroup(after: CommandGroupPlacement.pasteboard) {
+ Divider()
+ Button("Find...") {
+ withAnimation {
+ isSearching = isSearching != nil ? !isSearching! : true
+ }
+ }.keyboardShortcut(
+ "f", modifiers: EventModifiers([.command])
+ ).disabled(document == nil)
+ }
+