|
@@ -796,6 +796,11 @@ const char *OS_JavaScript::get_audio_driver_name(int p_driver) const {
|
|
|
}
|
|
|
|
|
|
// Clipboard
|
|
|
+extern "C" EMSCRIPTEN_KEEPALIVE void update_clipboard(const char *p_text) {
|
|
|
+ // Only call set_clipboard from OS (sets local clipboard)
|
|
|
+ OS::get_singleton()->OS::set_clipboard(p_text);
|
|
|
+}
|
|
|
+
|
|
|
void OS_JavaScript::set_clipboard(const String &p_text) {
|
|
|
OS::set_clipboard(p_text);
|
|
|
/* clang-format off */
|
|
@@ -958,6 +963,11 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
|
|
|
(['mouseover', 'mouseleave', 'focus', 'blur']).forEach(function(event, index) {
|
|
|
Module.canvas.addEventListener(event, send_notification.bind(null, notifications[index]));
|
|
|
});
|
|
|
+ // Clipboard
|
|
|
+ const update_clipboard = cwrap('update_clipboard', null, ['string']);
|
|
|
+ window.addEventListener('paste', function(evt) {
|
|
|
+ update_clipboard(evt.clipboardData.getData('text'));
|
|
|
+ }, true);
|
|
|
},
|
|
|
MainLoop::NOTIFICATION_WM_MOUSE_ENTER,
|
|
|
MainLoop::NOTIFICATION_WM_MOUSE_EXIT,
|