Add ⌘C support (#3072)

This commit is contained in:
Antoine Cœur 2022-05-14 05:03:07 +08:00 committed by GitHub
parent 7b34c09f26
commit 5026d43920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -640,6 +640,25 @@
return [self.fTorrentCell iconRectForBounds:[self rectOfRow:row]];
}
- (BOOL)acceptsFirstResponder
{
// add support to `copy:`
return YES;
}
- (void)copy:(id)sender
{
NSArray<Torrent*>* 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;