From 640515ad88de64348c61f6e6cc7b6f8da33f4bee Mon Sep 17 00:00:00 2001 From: pi-chan Date: Mon, 30 Jan 2017 15:34:42 +0900 Subject: [PATCH] =?UTF-8?q?=E2=8C=98C=20to=20copy=20image=20to=20pasteboar?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Fuwari/FloatWindow.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Fuwari/FloatWindow.swift b/Fuwari/FloatWindow.swift index c944bb3..3ad4358 100644 --- a/Fuwari/FloatWindow.swift +++ b/Fuwari/FloatWindow.swift @@ -58,6 +58,16 @@ class FloatWindow: NSWindow { fade(isIn: false) { self.floatDelegate?.close(floatWindow: self) } + case UInt16(kVK_ANSI_C): + DispatchQueue.main.asyncAfter(deadline: .now()) { + if let image = self.contentView?.layer?.contents { + let cgImage = image as! CGImage + let size = CGSize(width: cgImage.width, height: cgImage.height) + let nsImage = NSImage(cgImage: cgImage, size: size) + NSPasteboard.general().clearContents() + NSPasteboard.general().writeObjects([nsImage]) + } + } default: break }