Ultralight
Ultralight copied to clipboard
Event not triggered: oncontextmenu
Currently oncontextmenu for any html element is not triggered. Right clicks on onmousedown and onmouseup are triggered properly.
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
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);
}
};