mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 19:03:30 +00:00
Emscripten: Handling "external" clipboard #7851
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#7851
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
Version 1.91.0
Back-ends:
imgui_impl_glfw.cpp
Compiler, OS:
emscripten / browser
Full config/build information:
No response
Details:
With the release of ImGui 1.91.0 and the support for
emscripten-glfw, as you know, the clipboard is now supported in the browser environment. For example, you can now copy the build configuration (which can try for yourself with the demo I pushed with the PR)If you copy to the clipboard by calling
glfwSetClipboardString, then I store the string locally and push it to the external clipboard (which is why you can paste it outside the browser).If you then paste from the clipboard by calling
glfwGetClipboardString, then the clipboard string that was stored previously is returned.In other words, copy/paste from within the application works great.
The issue comes with pasting from the "external" clipboard: the Javascript API, which is the API that I need to use is asynchronous. For this purpose, in the latest version of
emscripten-glfw, I added a new API which reflects this API:I am using this API in my recently released WebGPU Shader Toy tool for the code editor class (
TextEditor) because I am in control of this logic: when I detect a "Paste" event (CTRL+V), I call the asynchronous API and when I receive the result, I do the actual Paste action.Of course this does not work with
ImGui::InputTextand I wanted to ask you if you could think of a way, or giving me pointers of whether this would be possible to do in ImGui (I tried to look at Shortcut routing but I don't know if that is even the right place to start...). I would be more than happy to do a PR for the work if this is something that is possible at all. Otherwise I could implement an entirely new control for my project.Thank you
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response