Add a file to the system clipboard

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?

1 Like

Windows.

Still looking for Mac solution

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

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…

3 Likes

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

1 Like

any news about copy / pasting from clipboard?

We solved it for Mac and Windows as above. Works well but I didn’t see anyone leaping to add it to JUCE main :wink:

3 Likes