Closed jmshal closed 6 years ago
Shortcuts like cmd+c, cmd+x works only for editable field. For non-editable fields, extension has to register key events interested. For more information please refer to https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_8.x/Documentation/CEP%208.0%20HTML%20Extension%20Cookbook.md#register-an-interest-in-specific-key-events
For eg. To copy text when cmd+c is pressed, extension has to register cmd+c using,
var CSLibrary = new CSInterface(); CSLibrary.registerKeyEventsInterest([{ "keyCode": 8, "metaKey": true }]);
function keyDownInBody(event) { if(event.keyCode == 67 && event.metaKey == true) { var selectedText = "" if (window.getSelection){ // all modern browsers and IE9+ selectedText = window.getSelection().toString(); document.execCommand("copy"); } }
Not sure if this is a deliberate choice made by the Adobe CEP developers, but I consider this a bug.
I have only tried this in InDesign so bar. Basically using the
cmd+c
keyboard shortcut after highlighting some text in the extension does not copy the text. But right clicking and selecting the "Copy" option does seem to work.In addition: highlighting some text in an
<input />
element & using the keyboard shortcut does work as expected.Using
contenteditable
does fix the issue, but then you have the overhead of having to manually maintain the content. I do not consider this a viable workaround.Using an
<input />
element does fix the issue (as mentioned previously), but you have to manually manage the width/height of the element based on the content within & the parent element's dimensions.I have yet to find a viable workaround for this bug - but maybe I'm missing something? It certainly seems as if this issue would have come up before now.
Additional info: