views:

102

answers:

1

Imagine I want a user to be able to copy-paste a selection of pixels from MSPaint into a browser-based app. Is this possible using JavaScript in any current browsers? Will it become possible in HTML5? If not, is it feasible using something like Flex/Silverlight, or is it simply not possible at this time, and you'd have to save a file and manually upload it?

update: sounds like HTML5 should allow it, but that's a way in the future to be genuinely useful. Some suggestions of Java applets and Flash are mentioned, probably Flash would be preferable since parts of the web-client would probably use Flex anyway... I'd rather not have requirement for Java and Flash in my site.

+2  A: 

There's a very thorough examination of this prior question: Wysiwyg with image copy/paste. It discusses possibly coming behavior in HTML5, as well as Flash and Java applet solutions that interact with the clipboard, and which you can then tie into JavaScript.


Questioner asked about Zeroclipboard's applicability. So, look at the file ZeroClipboard10.as and you'll see the click handler supports two data formats:

private function clickHandler(event:Event):void {
    // user click copies text to clipboard
    // as of flash player 10, this MUST happen from an in-movie flash click event
    Clipboard.generalClipboard.clear();
    Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, clipText);
    Clipboard.generalClipboard.setData(ClipboardFormats.HTML_FORMAT, clipText);
    ExternalInterface.call( 'ZeroClipboard.dispatch', id, 'complete', clipText );
}

The reference for ActionScript's ClipboardFormats constant indicates one of the formats is a BITMAP_FORMAT. So I think that's a pretty good start.

artlung
Thanks for the references. However I'm not clear how zeroclipboard is applicable, it talks about text and RTF. I'd love to see a discussion on the mechanics of how to get the contents of the system clipboard using Flash (using that library as a reference if applicable)
John
Updated with info on zeroclipboard! Hope that helps!
artlung
Those class references all say 'AIR only' and are part of flash.desktop. I think I'll give you the bounty, but maybe start a thread explicitly asking about Flash/Flex clipboards as well, on which your input is most welcome! Thanks.
John