Skip to content

Commit 1d89a52

Browse files
authoredJun 15, 2023
Add a quick "Copy to Clipboard" context menu. (huggingface#44)
Add a "Copy to Clipboard" context menu.
1 parent e03c0e0 commit 1d89a52

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed
 

‎Diffusion-macOS/GeneratedImageView.swift

+13-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,19 @@ struct GeneratedImageView: View {
3636
return AnyView(Image(systemName: "exclamationmark.triangle").resizable())
3737
}
3838

39-
return AnyView(Image(theImage, scale: 1, label: Text("generated"))
40-
.resizable()
41-
.clipShape(RoundedRectangle(cornerRadius: 20))
39+
return AnyView(
40+
Image(theImage, scale: 1, label: Text("generated"))
41+
.resizable()
42+
.clipShape(RoundedRectangle(cornerRadius: 20))
43+
.contextMenu {
44+
Button {
45+
NSPasteboard.general.clearContents()
46+
let nsimage = NSImage(cgImage: theImage, size: NSSize(width: theImage.width, height: theImage.height))
47+
NSPasteboard.general.writeObjects([nsimage])
48+
} label: {
49+
Text("Copy Photo")
50+
}
51+
}
4252
)
4353
case .failed(_):
4454
return AnyView(Image(systemName: "exclamationmark.triangle").resizable())

0 commit comments

Comments
 (0)
Please sign in to comment.