浏览代码

Merge pull request #184 from UnityTech/iphoneplus_view

webgl copy-paste text
/main
GitHub 6 年前
当前提交
0d09b470
共有 3 个文件被更改,包括 26 次插入1 次删除
  1. 14
      Runtime/Plugins/platform/webgl/webgl.jslib
  2. 11
      Runtime/service/clipboard.cs
  3. 2
      Samples/UIWidgetSample/HoverRecognizerSample.cs

14
Runtime/Plugins/platform/webgl/webgl.jslib


UIWidgetsMessageSetObjectName: function (name) {
UIWidgetsPlugin.getMessageManager().setObjectName(Pointer_stringify(name));
},
UIWidgetsCopyTextToClipboard: function (text) {
var el = document.createElement('textarea');
el.value = Pointer_stringify(text);
el.setAttribute('readonly', '');
el.style = {
position: 'fixed',
left: '-9999px',
};
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}
};

11
Runtime/service/clipboard.cs


using System.Runtime.InteropServices;
using RSG;
using UnityEngine;

public class UnityGUIClipboard : Clipboard {
protected override IPromise setClipboardData(ClipboardData data) {
#if UNITY_WEBGL
UIWidgetsCopyTextToClipboard(data.text);
#else
#endif
return Promise.Resolved();
}

}
#if UNITY_WEBGL
[DllImport ("__Internal")]
internal static extern void UIWidgetsCopyTextToClipboard(string text);
#endif
}
}

2
Samples/UIWidgetSample/HoverRecognizerSample.cs


return new Scaffold(
appBar: new AppBar(
title: new Center(
child: new Text("Test Hover Widget")
child: new SelectableText("Test Hover Widget")
)
),
body: new Card(

正在加载...
取消
保存