W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2014

RE: [clipboard events] click-to-copy support could be hasFeature discoverable?

From: Ben Peters <Ben.Peters@microsoft.com>
Date: Tue, 20 May 2014 21:24:40 +0000
To: "Hallvord R. M. Steen" <hsteen@mozilla.com>, James Greene <james.m.greene@gmail.com>
CC: Anne van Kesteren <annevk@annevk.nl>, public-webapps <public-webapps@w3.org>
Message-ID: <643004c5e93546a4af5fe4a98a659450@BLUPR03MB437.namprd03.prod.outlook.com>
> > Getting back to the question of feature discoverability, if we go with
> > using `document.execCommand` instead of synthetic event dispatching
> > with side effects, then I would expect the proper support checks to be
> > conducted with `document.queryCommandSupported` and
> `document.queryCommandEnabled`.
> 
> It would sort of be inconsistent with how queryCommandEnabled works and
> is typically used today. As far as I can tell it's typically used to enable/disable
> buttons in a editor UI, while you move through the text. Having
> queryCommandEnabled('copy') return true only during click event processing
> would for a typical editor make the "copy" button enabled only while you
> click in the document.. It would take some special-casing and logic to work
> around that.
> 
> What if we extend queryCommandEnabled somewhat and allow
> 
> document.queryCommandEnabled('copy', {'userTriggered':true}) ?
> -Hallvord

I see three different levels of support a browser could have for copy:
1) document.execCommand('copy') fires a clipboard event, and if preventDefault isn't called the browser puts the selected text on the clipboard
2) document.execCommand('copy') fires a clipboard event, but no further action happens regardless of preventDefault
3) document.execCommand('copy') does nothing and returns false.

1 is what IE does today. I believe Chrome and Firefox do 3. Are we saying that 1 or 2 is the desired behavior for click-to-copy?

To detect 3, it seems like queryCommandSupported('copy') should return false, regardless of focus of what event you're in.
Do we need to be able to detect 1 vs 2? Or are we only interested in knowing if the clipboard event will fire?
Received on Tuesday, 20 May 2014 21:25:10 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:24 UTC