From 5026d4392006df8c429a9c351d07b20c08b31946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20C=C5=93ur?= Date: Sat, 14 May 2022 05:03:07 +0800 Subject: [PATCH] =?UTF-8?q?Add=20=E2=8C=98C=20support=20(#3072)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- macosx/TorrentTableView.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/macosx/TorrentTableView.mm b/macosx/TorrentTableView.mm index f3d3b44aa..b9decd8da 100644 --- a/macosx/TorrentTableView.mm +++ b/macosx/TorrentTableView.mm @@ -640,6 +640,25 @@ return [self.fTorrentCell iconRectForBounds:[self rectOfRow:row]]; } +- (BOOL)acceptsFirstResponder +{ + // add support to `copy:` + return YES; +} + +- (void)copy:(id)sender +{ + NSArray* selectedTorrents = self.selectedTorrents; + if (selectedTorrents.count == 0) + { + return; + } + NSPasteboard* pasteBoard = NSPasteboard.generalPasteboard; + NSString* links = [[selectedTorrents valueForKeyPath:@"magnetLink"] componentsJoinedByString:@"\n"]; + [pasteBoard declareTypes:@[ NSStringPboardType ] owner:nil]; + [pasteBoard setString:links forType:NSStringPboardType]; +} + - (void)paste:(id)sender { NSURL* url;