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

Copy event listeners not working #16

Open
ifancyabroad opened this issue Oct 15, 2021 · 0 comments
Open

Copy event listeners not working #16

ifancyabroad opened this issue Oct 15, 2021 · 0 comments

Comments

@ifancyabroad
Copy link

I am trying to use RPGUI for a React project, however I am running into an issue where event handlers are not being passed to input fields. On closer inspection it seems the issue lies with the below function:

// copy all event listeners from one element to the other
RPGUI.copy_event_listeners = function(from, to)
{
    // copy all event listeners
    if (typeof getEventListeners == "function")
    {
        var events = getEventListeners(from);
        for(var p in events) {
            events[p].forEach(function(ev) {
                // {listener: Function, useCapture: Boolean}
                to.addEventListener(p, ev.listener, ev.useCapture);
            });
        }
    }

    // now copy all attributes that start with "on"
    for (attr in from)
    {
        if (attr.indexOf("on") === 0)
        {
            to[attr] = from[attr];
        }
    }
};

This appears to be because the getEventListeners function is only defined in the console for devtools and is otherwise not available.

Thanks,

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

No branches or pull requests

1 participant