Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC: Support Copy/Paste on WASM build outside the application border #1542

Merged
merged 4 commits into from
Feb 13, 2024

Conversation

exsilium
Copy link
Contributor

@exsilium exsilium commented Feb 11, 2024

Problem description

WASM build does not support copy/paste beyond the application. Meaning, there's no practical way of sending text back and forth across the application border.

There are lengthy threads why this is a technical challenge in WASM/Browser world, e.g:

Implementation description

Implements a workaround solution as Header only C++ library, as proposed and implemented at: https://github.com/Armchair-Software/emscripten-browser-clipboard

Maybe there are cleaner ways of achieving the functionality. Definitely would like to have some discussion around this. 👀

ℹ️ The proposed PR "works for me" on Windows, using CTRL-C/V shortcuts to copy text from and to the application. On MacOS the system shortcut to Paste is different from what ImHex has defined. This results in system Paste shortcut of command-V triggering the browser callback to synchronise the application clipboard, but no actual Paste takes place within ImHex.

If there would be a clean way to trigger the paste command, that would be wonderful (or get the context and references to write the data to the cursor, but I was unable to find a clean solution). The only proposed solutions in the referenced threads were about triggering paste event internally via Key events. This seemed wonky 🙃 , so is not currently implemented. At the moment the paste on MacOS is command+V followed by control+V.

Additional things

This is definitely a stopgap solution before the ImGui and Emscripten take a more proper solution in enabling Copy/Paste outside the application borders. However, I feel like this is a must have capability to make the WASM build more useful, not just for trying out ImHex.

Cheers! 🍻

@WerWolv
Copy link
Owner

WerWolv commented Feb 11, 2024

Hey!

Thank you very much for the PR! This has been bothering me as well and we couldn't find a good way to do it.
Even if might just be a temporary solution, it's definitely much better than not having it.

@exsilium
Copy link
Contributor Author

Thank you for the positive feedback, @WerWolv , granted the pipeline goes through and there are no specific comments to this PR, I'm happy if this gets merged as is. 🙇

@WerWolv WerWolv merged commit d70f742 into WerWolv:master Feb 13, 2024
14 of 15 checks passed
@WerWolv
Copy link
Owner

WerWolv commented Feb 13, 2024

All good, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants