mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-16 16:28:14 +00:00
Support clipboard copy/paste on web
This commit is contained in:
@@ -1903,9 +1903,11 @@ const char *GetClipboardText(void)
|
|||||||
{
|
{
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
return glfwGetClipboardString(CORE.Window.handle);
|
return glfwGetClipboardString(CORE.Window.handle);
|
||||||
#else
|
|
||||||
return NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
return emscripten_run_script_string("navigator.clipboard.readText()");
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set clipboard text content
|
// Set clipboard text content
|
||||||
@@ -1914,6 +1916,9 @@ void SetClipboardText(const char *text)
|
|||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
glfwSetClipboardString(CORE.Window.handle, text);
|
glfwSetClipboardString(CORE.Window.handle, text);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
emscripten_run_script(TextFormat("navigator.clipboard.writeText('%s')", text));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show mouse cursor
|
// Show mouse cursor
|
||||||
|
Reference in New Issue
Block a user