aspose file tools*
The moose likes GWT and the fly likes Copying image to clipboard Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Copying image to clipboard" Watch "Copying image to clipboard" New topic
Author

Copying image to clipboard

jasdeep parmar
Greenhorn

Joined: Oct 06, 2008
Posts: 20
Hi,

I am using smartgwt 2.2 for my application. I have customized context menu on right click on an image, I need to add a copy to systems clipboard functionality so i can copy an image from app then paste in somewhere else like (paint) . Is there a way I can accomplish it?

thanks
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10522
    
    9

Why are you writing your own functionality for this? Doesn't the browser provide this already?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
jasdeep parmar
Greenhorn

Joined: Oct 06, 2008
Posts: 20
the reason I am writing my own is becuause i have to provide other customized options in that menu which browser doesn't provide..

thanks
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

if it helps:

javascript for copying image from a div

var div = document.getElementById('divId');
div.contentEditable = 'true';
var controlRange;
if (document.body.createControlRange) {
controlRange = document.body.createControlRange();
controlRange.addElement(div);
controlRange.execCommand('Copy');
}
div.contentEditable = 'false';

I dont think this will work in non IE browsers and i advise against using browser specific script.

Always remember that you are working on a browser, Its never going to act like a desktop application,
You cannot (for example) drag and drop files from your pc into your application.


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Copying image to clipboard