Re: [clipboard-apis] Should queryCommandEnabled(cut|copy|paste) trigger onbefore* events? (#4)

@gauntface well, these events are a bit .. weird. But think of it this way (or read the spec): the "default action" of the event is to run the UA's built-in logic for enabling/disabling copy/cut/paste commands. The built-in logic will likely conclude for example that "copy" should not be enabled if there is no selection. When you override this (by preventing the "default" outcome) the command will end up being enabled.

As for the use case, say you have a complex web app where one UI library handles copy/cut/DnD and another component is responsible for rendering some buttons. Rather than having a tight coupling between those components, the library handling buttons could call queryCommandEnabled('copy') and the DnD library could listen to 'beforecopy' and call preventDefault() if it wanted the button to be enabled.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/4#issuecomment-108839746

Received on Thursday, 4 June 2015 10:57:44 UTC