Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Copying image to clipboard

 
jasdeep parmar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you writing your own functionality for this? Doesn't the browser provide this already?
 
jasdeep parmar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1263
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic