Tweak JS clipboard API integration to work on Firefox

According to the spec, 'copy' execCommand requires that the text is
selected with Selection API. The text input element is created on
the fly, attached to the parent and the text is range selected.
While this approach reliably works on latest Chrome version, it seems
not to be sufficient for Firefox 41: selection only works reliably,
when the element has acquired the focus first.

Change-Id: I7bcee742bb9896aa502c0b75fe7718571c1cb135
This commit is contained in:
David Ostrovsky
2015-10-24 20:00:46 +02:00
parent 44239b8f2e
commit 630f58ae80

View File

@@ -274,6 +274,7 @@ public class CopyableLabel extends Composite implements HasText {
try {
t.setText(getText());
content.add(t);
t.setFocus(true);
t.selectAll();
boolean ok = execCommand("copy");