cacao icon indicating copy to clipboard operation
cacao copied to clipboard

Implement `writeObjects` for Pasteboard

Open jdmremi opened this issue 3 years ago • 2 comments
trafficstars

Referencing this Stack Overflow article, the following code allows the user to copy some object (in this case, a file) to the clipboard:

NSURL *object = [[NSURL alloc] initFileURLWithPath:@"/Users/username/Desktop/main.png"];
NSPasteboard *pb = [NSPasteboard generalPasteboard];
[pb clearContents];

NSArray *objectsToCopy = [[NSArray alloc] initWithObjects:object, nil];
BOOL pasted = [pb writeObjects:objectsToCopy];

if(pasted) // paste was successful
    NSLog(@"pasted");

[object release];
[objectsToCopy release];
[pb release];

However, after reading through the documentation/the Pasteboard implementation, it does not appear that there is a straightforward way to do this by using Cacao, as there is only support for writing text to the Pasteboard (clipboard).

jdmremi avatar Dec 28 '21 00:12 jdmremi

This should actually be easier in the 0.3 branch, which I need to land. Will revisit it then - hopefully within the next week or two.

ryanmcgrath avatar Dec 28 '21 00:12 ryanmcgrath

Hey! Any update on this request?

jdmremi avatar Mar 16 '22 00:03 jdmremi