RPGUI icon indicating copy to clipboard operation
RPGUI copied to clipboard

Copy event listeners not working

Open ifancyabroad opened this issue 4 years ago • 0 comments

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,

ifancyabroad avatar Oct 15 '21 08:10 ifancyabroad