This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Several fixes and improvements #16
Open
Trisibo
wants to merge
10
commits into
greggman:master
Choose a base branch
from
Trisibo:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…sed to the JavaScript event handlers.
…LCopyAndPasteAPI.cs" before the "using" directives, so it can be uncommented without errors or having to move it manually.
…rol" and "command" properties set as true, which works on both mac and Windows with only one "ProcessEvent" call. Moved the event creation to a separate method.
…ld, instead of first checking for a legacy input field, to save a check in most situations.
…isually updated in some situations.
Thanks for the PR ❤️ What do you think about you becoming the main repo for this? I'm not actually a Unity developer. I wrote this a just kind of a 1 day hobby thing. I'm not sure I've used Unity in over a year, maybe 2yrs |
That would be OK. I've never done a repo transfer or similar, how do you want to do it? |
I think I can just mark this repo as archived after I've changed the README to point to https://github.com/Trisibo/unity-webgl-copy-and-paste/ |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I made several fixes and improvements, I'm opening a single pull request with all of them, sorry if you preferred one pull request per change. These are the changes:
When I tested on Firefox on Windows, pasting didn't work at all. Apparently, setting
GUIUtility.systemCopyBuffer
to paste doesn't work there (not sure about other browsers, I don't even know why it works on some, seems a weird behaviour to me), so I added aSendKey("v")
call, but then in some browsers it would paste the text twice. What seems to work on all browsers is to setGUIUtility.systemCopyBuffer
, then callSendKey("v")
, and then setGUIUtility.systemCopyBuffer
tonull
, which prevents the second paste (it occurs on the next frame, so at that point it has no text). The only issue would be that other code cannot useGUIUtility.systemCopyBuffer
at that point to know what was pasted, but I consider it a very minor issue compared to pasting not working at all in some browsers.Added the
forceLabelUpdate
parameter toSendKey
, used when pasting, since in some browsers the text was pasted but the label wasn't updated visually until another key was pressed. I usedForceLabelUpdate
to do the update.When creating a keyboard event for processing, instead of using the base key with added "%" and "^" texts and calling
ProcessEvent
twice, now the code creates an event with the key unchanged and thecontrol
andcommand
properties set to true, which works fine on both Windows and Mac with just one call toProcessEvent
.Substituted the deprecated
Window.event
property with the event passed to the JavaScript event handlers: https://developer.mozilla.org/en-US/docs/Web/API/Window/eventMoved the
#define WEBGL_COPY_AND_PASTE_SUPPORT_TEXTMESH_PRO
line before the usings, just for convenience so it can be uncommented right away without having to move it due to defines being invalid elsewhere in code.When TextMesh Pro support is enabled, the code will check if the object has a TextMesh Pro field first, instead of first checking for a legacy field; most of the time, when TMP support is added it would be expected that objects use a TMP field, so checking that first would avoid the check for the legacy one in most cases.
Added a check to ensure
EventSystem.current
is not null before using it.I have confirmed that it works on: