Skip to content

Partial Javascript clipboard support#29298

Merged
akien-mga merged 3 commits into
godotengine:masterfrom
Faless:javascript/clipboard
Jun 1, 2019
Merged

Partial Javascript clipboard support#29298
akien-mga merged 3 commits into
godotengine:masterfrom
Faless:javascript/clipboard

Conversation

@Faless

@Faless Faless commented May 29, 2019

Copy link
Copy Markdown
Collaborator

Partial fix for #12587 . I'm not sure it can be fully fixed for now, see note below. Partially address #12587

In this PR:

Add OS clipboard set support to OS Javascript

This is straight forward, and seems to work quite well with the ClipboardAPI. It's async, so it doesn't happen

Add OS clipboard support to paste 'events' (updating local clipboard)

Listen to paste events to update local clipboard.
CTRL+V still not working out of the box.
To do that, We would need to change how we handle keypress, most likely making it worse and less safe. In the end, I'm not sure we can fix it properly for now.
Maybe in the future, with the Clipboard API, support of which is still pretty limited on chrome, and only available to extensions in Firefox.

For now, you can paste via:

  • Browser bar -> Edit -> Paste.
  • Middle mouse click (Linux only, copies secondary clipboard).

And THEN press CTRL+V

Implement Clipboard API read when supported. (chrome only atm)

Being async, the first time a value is pasted GUI elements will still return the previous one(*).
This at least until 'clipboardchange' window event gets implemented by user agents.

(*)Note: We could implement some sort of clipboard manager that refreshes the value every few seconds and keeps the local keyboard in sync. It would still be chrome only, and it seems a bit hacky, but it would probably work.

Some references:
Clipboard (readText limited to extensions, writeText limited to user callbacks. See also FF1515122 )

clipboardchange (supported by no-one).

Faless added 3 commits May 28, 2019 12:59
Listen to paste events to update local clipboard.
CTRL+V still not working out of the box.
To do that, We would need to change how we handle keypress, most likely
making it worse and less safe. In the end, I'm not sure we can fix it
properly for now. Maybe in the future, with the Clipboard API, support
of which is still pretty limited on chrome, and only available to
extensions in Firefox.

For now, you can paste via:
- Browser bar -> Edit -> Paste.
- Middle mouse click (Linux only, copies secondary clipboard).

And THEN press CTRL+V
Being async, the first time a value is pasted GUI elements will still
return the previous one.
This at least until 'clipboardchange' window event gets implemented by
user agents.
@akien-mga
akien-mga merged commit f7953dd into godotengine:master Jun 1, 2019
@akien-mga

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment