HTML5: Let Clipboard.text setter copy to system clipboard

This commit is contained in:
Danny Wilson
2017-01-17 11:11:55 +01:00
parent 22b8864483
commit c74f43b07e

View File

@@ -6,7 +6,10 @@ import lime._backend.native.NativeCFFI;
#if flash
import flash.desktop.Clipboard in FlashClipboard;
#elseif js
import lime._backend.html5.HTML5Window;
import js.Browser.document;
@:access(lime._backend.html5.HTML5Window)
#end
#if !lime_debug
@@ -66,9 +69,20 @@ class Clipboard {
#elseif js
_text = value;
#if html5
if (document.queryCommandEnabled("copy"))
#if html5 // HTML5 needs focus on <input> field for clipboard events to work
if (HTML5Window.textInput != null) {
HTML5Window.textInput.focus();
HTML5Window.textInput.value = _text;
HTML5Window.textInput.select();
}
if (document.queryCommandEnabled("copy")) {
document.execCommand("copy");
}
#end
return value;