Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Hint for anyone trying to use this with runtime UI Toolkit #10

Open
patrickp-unity3d opened this issue Mar 2, 2023 · 0 comments
Open

Comments

@patrickp-unity3d
Copy link

You'll need to populate s_RootVisualElement, but otherwise paste works thanks to this excellent plugin.

    static void SendKey(string baseKey)
    {
        if (s_RootVisualElement == null)
            return;
        
        string appleKey = "%" + baseKey;
        string naturalKey = "^" + baseKey;

        {
            var evt = Event.KeyboardEvent(naturalKey);
            using var keyEvt = KeyDownEvent.GetPooled(evt);
            s_RootVisualElement.SendEvent(keyEvt);
        }
        {
            var evt = Event.KeyboardEvent(appleKey);
            using var keyEvt = KeyDownEvent.GetPooled(evt);
            s_RootVisualElement.SendEvent(keyEvt);
        }
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant