Ultralight icon indicating copy to clipboard operation
Ultralight copied to clipboard

Event not triggered: oncontextmenu

Open Superxwolf opened this issue 6 years ago • 2 comments

Currently oncontextmenu for any html element is not triggered. Right clicks on onmousedown and onmouseup are triggered properly.

Superxwolf avatar Nov 09 '19 15:11 Superxwolf

This potentially breaks right-click also in the inspector view, and that's also a bit annoying since you can't do things like right click on element to edit the whole HTML etc EDIT: submitted PR for inspector: https://github.com/ultralight-ux/WebCore/pull/11

p0358 avatar Nov 26 '22 02:11 p0358

Workaround for code that requires this event is:

window.addEventListener("mousedown", function(event) {
    if (event.button === 2) { // right-click
        const contextMenuEvent = new MouseEvent("contextmenu", {
            view: window,
            bubbles: true,
            cancelable: true,
            screenX: event.pageX,
            screenY: event.pageY,
            clientX: event.pageX,
            clientY: event.pageY,
            ...event
        });
        event.target.dispatchEvent(contextMenuEvent);
    }
};

p0358 avatar Nov 28 '22 11:11 p0358