W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2012

[Clipboard API] The before* events

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Tue, 30 Oct 2012 16:42:40 +0000
Message-ID: <20121030164240.r5cue81pxwcgkcgg@staff.opera.com>
To: public-webapps@w3.org
Cc: Ryosuke Niwa <rniwa@webkit.org>, Aryeh Gregor <ayg@aryeh.name>, Daniel Cheng <dcheng@chromium.org>, Bjoern Hoehrmann <derhoermi@gmx.net>, Sebastian Markbåge <sebastian@calyptus.eu>
I'm looking at the beforecut, beforecopy and beforepaste events. I  
don't entirely understand their intent, it seems even more obscure  
than I expected..

Nothing in the official MSDN documentation [1] really explains the  
interaction between beforecopy and copy (given that you can control  
the data put on the clipboard from the copy event without handling  
beforecopy at all, the demo labelled "this example uses the  
onbeforecopy event to customize copy behavior" doesn't really make  
sense to me either.)

I was under the impression that you could handle the before* events to  
control the state of copy/cut/paste UI like menu entries. However,  
when tweaking a local copy of the MSDN code sample [2], I don't see  
any difference in IE8's UI whether the event.returnValue is set to  
true or false in the beforecopy listener.

Another problem with using before* event to control the state of  
copy/cut/paste UI is that it only works for UI that is shown/hidden on  
demand (like menus) and not for UI that is always present (like  
toolbar buttons). I'm not aware of web browsers that have UI with  
copy/cut/paste buttons by default, but some browsers are customizable  
and some might have toolbar buttons for this.

I'm wondering if specifying something like

navigator.setCommandState('copy', false); // any "copy" UI is now  
disabled until app calls setCommandState('copy', true) or user  
navigates away from page

would be more usable? A site/app could call that at will depending on  
its internal state. Or, if we want to handle the data type stuff, we  
could say

navigator.setCommandState('paste', true, {types:['text/plain','text/html']});

to enable any "paste plain text" and "paste rich text" UI in the browser?

[1] http://msdn.microsoft.com/en-us/library/ms536901(VS.85).aspx
Received on Tuesday, 30 October 2012 16:43:19 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:49 UTC