File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Copying image to clipboard

jasdeep parmar

Joined: Oct 06, 2008
Posts: 20

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?

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10825

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

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..

salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 1136

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();
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.

I agree. Here's the better link:

I agree. Here's the link:
subject: Copying image to clipboard
It's not a secret anymore!