summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2022-02-20 22:07:52 +0100
committerRay <[email protected]>2022-02-20 22:07:52 +0100
commit6e9ec253c89a9f37e7cbe1f1db382121dcbb61c1 (patch)
tree28cca75bb8e7b1ea19f8db48f143b6e39c358907 /src
parent937e7b3dd92bb8fc2b0cd4a334bd277cbd4b2059 (diff)
downloadraylib-6e9ec253c89a9f37e7cbe1f1db382121dcbb61c1.tar.gz
raylib-6e9ec253c89a9f37e7cbe1f1db382121dcbb61c1.zip
Support clipboard copy/paste on web
Diffstat (limited to 'src')
-rw-r--r--src/rcore.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/rcore.c b/src/rcore.c
index fc781219..58c8c4ce 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -1903,9 +1903,11 @@ const char *GetClipboardText(void)
{
#if defined(PLATFORM_DESKTOP)
return glfwGetClipboardString(CORE.Window.handle);
-#else
- return NULL;
#endif
+#if defined(PLATFORM_WEB)
+ return emscripten_run_script_string("navigator.clipboard.readText()");
+#endif
+ return NULL;
}
// Set clipboard text content
@@ -1914,6 +1916,9 @@ void SetClipboardText(const char *text)
#if defined(PLATFORM_DESKTOP)
glfwSetClipboardString(CORE.Window.handle, text);
#endif
+#if defined(PLATFORM_WEB)
+ emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text));
+#endif
}
// Show mouse cursor