Hi there after the idea stucks in my head for a while now I just started to develop it for extjs.

One most used features in applications are cut copy and paste. And after apple implemented it for the Iphone i ask my self why dont do that for Ext too.

"because you do not have acces to the Clipboard" many of you will shout.
Of cause not. But there is a way to use it anyhow!!!

You would like to see it in action first? Here is a little demo:

http://www.crp.de/Shared/extjs/examples/copyPasteExample/copyPasteExample.html


After you have seen the demo you may whant to know how its been done




I just pasted from Documentation.

Represents the base Plugin for adding Cut/Copy/Paste capabilities to a component.


The plugin Bases on a tricky little Bypass trick.
The plugin adds two hidden native HTMLElements to the body.
A Textarea for bypassing to clipboard. And a Iframe with editmode=On for bypassing from the Clipboard.

After a Component that instanciates this Plugin gets renderd the plugin attaches the
key events of ctrl+x ctrl+c ctrl+v two its own functions.

Since the browser fires the javascript keyevent before it does the native cutting, copieing and pasting stuff
we can use the time before the browser in example coping a text into the nativ System
Clipboard to selecting the text we want to have in the Clipboard.

This little hack makes the whole plugin possible.

Lets Clarify by explaining what the copyHandler, attached to the ctrl+c does.

First of all it saves a few states
- what was the caret State (the selection range)
- what was the marked Text (would normaly into the clipboard)

Than it asks the plugins client to build the copyIdentifier (this is what actualy does it way into the clipboard)
Than the the Magic Happens:
-The Value you returnd in the buildCopyIdentifierString function becomes the value of the Textarea attached to this component
-The Textarea gets its focus und all the text inside gets selected.
-Wait for about 10 Milliseconds and the Browser will have done the rest for you
-Woallla the value you just created via the buildCopyIdentifierString is now in the
native System Clipboard.
And the better thing about that: u exactly knwo about that string.
After all that, the copyToClipboard function with the IdentifierString gets called.

The cut Functionionalety is quiet similiar.

The Paste Function works a bit different.
First of all it saves a few states
- what was the caret State (the selection range)

Next Step is to focus the Iframe and set its innerHTML to '';
no we just wait for about 10 Milliseconds to let the browser paste the value from the
clipboard into the Iframe.
Now we call the plugins client pasteFromClipboard function under the scope of the client with the string from the iframes innerHTML
If this function retunrns undfined we simulate the default behavior.



If you got any questions just ask. Maybe you could try the demo and send some feedback + ?bugs?.

In the next Post I will place in the whole readable code for the plugin used in the Example