Page 1 of 1

Placing an image on the clipboard - OSX

Posted: Sun Dec 08, 2013 12:04 pm
by Simon Knight
I am attempting to use the following code to place a jpeg image onto the clipboard so that it may be pasted into an Apple Pages document, my live code application has a list of thumbnails and the user selects an image thumbnail so that the full size image may be used in a 3rd party application such as Apple Pages.

I planned on using the clipboard as the means of transferring to image data from my livecode application to Pages but I have encountered problems when attempting to do the paste. The file path is correct and the correct image is being processed but when I try to paste it into pages this error is posted: "The media can't be used because you don'y have access privileges, or because it has no content or is corrupt".

Well I do have access and I am able to post the image back into livecode so it seems that Pages does not like the format. Any ideas?

Code: Select all

on mouseUp
   put fld"folder" & "/" & "testimage.jpg" into tTarget
   
   import paint from file tTarget  //imports the image into the stack/card
   set the clipboarddata["image"] to the last image
   --copy the last image
   delete the last image
end mouseUp

Re: Placing an image on the clipboard - OSX

Posted: Thu Dec 12, 2013 11:53 am
by Simon Knight
There is no fault with Livecode, Apple Pages or the code I used. It seems that the data on the clipboard became corrupted such that other applications could not read the data while Livecode could. It is probably a good idea to flush the clipboard before use. I am not sure how to do this using Livecode commands but found this Applescript to perform the flush :

Code: Select all

tell application "System Events" to set the clipboard to ""