This repository was archived by the owner on Apr 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,20 @@ var UIWidgetsLibrary = {
56
56
57
57
UIWidgetsMessageSetObjectName : function ( name ) {
58
58
UIWidgetsPlugin . getMessageManager ( ) . setObjectName ( Pointer_stringify ( name ) ) ;
59
+ } ,
60
+
61
+ UIWidgetsCopyTextToClipboard : function ( text ) {
62
+ var el = document . createElement ( 'textarea' ) ;
63
+ el . value = Pointer_stringify ( text ) ;
64
+ el . setAttribute ( 'readonly' , '' ) ;
65
+ el . style = {
66
+ position : 'fixed' ,
67
+ left : '-9999px' ,
68
+ } ;
69
+ document . body . appendChild ( el ) ;
70
+ el . select ( ) ;
71
+ document . execCommand ( 'copy' ) ;
72
+ document . body . removeChild ( el ) ;
59
73
}
60
74
} ;
61
75
Original file line number Diff line number Diff line change
1
+ using System . Runtime . InteropServices ;
1
2
using RSG ;
2
3
using UnityEngine ;
3
4
@@ -29,13 +30,23 @@ public static IPromise<ClipboardData> getData(string format) {
29
30
30
31
public class UnityGUIClipboard : Clipboard {
31
32
protected override IPromise setClipboardData ( ClipboardData data ) {
33
+ #if UNITY_WEBGL
34
+ UIWidgetsCopyTextToClipboard ( data . text ) ;
35
+ #else
32
36
GUIUtility . systemCopyBuffer = data . text ;
37
+ #endif
38
+
33
39
return Promise . Resolved ( ) ;
34
40
}
35
41
36
42
protected override IPromise < ClipboardData > getClipboardData ( string format ) {
37
43
var data = new ClipboardData ( text : GUIUtility . systemCopyBuffer ) ;
38
44
return Promise < ClipboardData > . Resolved ( data ) ;
39
45
}
46
+
47
+ #if UNITY_WEBGL
48
+ [ DllImport ( "__Internal" ) ]
49
+ internal static extern void UIWidgetsCopyTextToClipboard ( string text ) ;
50
+ #endif
40
51
}
41
52
}
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public override Widget build(BuildContext context) {
35
35
return new Scaffold (
36
36
appBar : new AppBar (
37
37
title : new Center (
38
- child : new Text ( "Test Hover Widget" )
38
+ child : new SelectableText ( "Test Hover Widget" )
39
39
)
40
40
) ,
41
41
body : new Card (
You can’t perform that action at this time.
0 commit comments