Add a file to the system clipboard


#1

The JUCE system clipboard only allows you to add a text string, presumably it’s not a massive extension of this to allow files to be put in the clipboard, or is it? Anyone know?


#2

Windows.

Still looking for Mac solution


#3

Apparently:

    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];
    ```

#4

Nice… I just found that link to the reference: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/PasteboardGuide106/Articles/pbConcepts.html#//apple_ref/doc/uid/TP40008101-SW8

Would be cool to make that available to the SystemClipBoard…


#5

I guess it’ll need solving for iOS, Android and Linux to be an official feature?