Read/Write clipboard

Monkey Targets Forums/HTML5/Read/Write clipboard

Supertino(Posted 2012) [#1]
Hi all

Making my editor and with the absence of any file read/write I have gone the route of saving my level data in google docs, at the moment I just output the level string to the console and copy/paste from that but be good to be able to import strings too.

I am sure this is possible but lack the mad skills to make that happen could some one help me out?


Supertino(Posted 2012) [#2]
Well seems I have to make a external .js file - got as far as getting an "hello world" or 1+2 function working but all the javascript clipboard code I can find requires additional java module imports - I have no clue how to handle those.


impixi(Posted 2012) [#3]
There is a HTML5 Clipboard API working draft, but I don't know if there's any browser support yet. Will look into it later when I have some time...


impixi(Posted 2012) [#4]
Browser support for that Clipboard API is poor at this stage. But you should be able to utilize the clipboardData object via JavaScript (without the need for additional java module imports) and then wrap it for Monkey usage. Unless I misunderstand what you're trying to do...

What is it specifically you're trying to do with the clipboard?


impixi(Posted 2012) [#5]
Okay, i'm reading about that clipboardData object: apparently you can only call the getData method from within an onpaste event handler. That could certainly be a problem for some applications...

EDIT: Yep, according to my test code, both IE9 and Chrome17 adhere to that getData 'security' restriction. Bummer...

EDIT2: Actually IE9 does not play nice with getData at all.


Supertino(Posted 2012) [#6]
Hi impixi, thanks for taking a look, yeah I read there might be security issue so was taken out of most modern browsers.

Oh well not a huge loss where there is a will there is a way, I can get monkey to read/write HTML text boxes so that will do.