Clipboard access through events

Hi,

Clipboard functionality is not just something nice to
have but something which people want to see in an
application weather or not it is SVG.
When writing your own SVG app you can easyly implement
a clipboard, but there is no way for you to get access
to the system clipboard.
(Besides using IE with some HTML-SVG communication,
blagh, bad hack !)
This is not good for interoperatability.
People have some security concerns with accessing the
system clipboard.
I do partially agree with them, but that's only
looking at the cliboard as some object to write to or
read from if the user wants the app to or not.

But what if the user initiates a cut or paste action.
Would it not mean that the user actually wanted to cut
or paste something?
Unless I am "accidently" hiting Ctrl-V, I really mean
to paste what I have in my clipboard.
What are the security concerns then?

My suggestion is to have an event driven Clipboard.
The clipboard is just a DOM EventTarget one can add
EventListeners to.
The following events should be available:

ClipboardPaste, ClipboardCut, ClipboardCopy.
These events should be fired when the user hits the
shortcut keys for either operation or selects it from
a menu ...

The paste event contains the data to be pasted so it
can be used by the listener:

handleEvent(evt){
  data = evt.data
  doSomethingWith(data)
}

For the cut and the copy events the event object does
not contain any data. setting the data though will
transport that data to the system clipboard:

handleEvent(evt){
  evt.data = dataToBeCopiedToTheClipboard
}

One could think about adding information about the
data in the events as well. For example if it is text
or binary or ...

I can't see any security problems there and it should
not be difficult to implement it either.


So, what do you think?


Jan

PS:
Maybe it should be part of another spec like DOM3
events.


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

Received on Monday, 5 April 2004 08:39:22 UTC