Placing an image on the clipboard - OSX

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Placing an image on the clipboard - OSX

Post by Simon Knight » Sun Dec 08, 2013 12:04 pm

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
best wishes
Skids

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Placing an image on the clipboard - OSX

Post by Simon Knight » Thu Dec 12, 2013 11:53 am

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 ""
best wishes
Skids

Post Reply