wrapNativeMouseEvent function
Helper util that wraps a native MouseEvent in a SyntheticMouseEvent.
Used where a native MouseEvent is given and a SyntheticMouseEvent is needed.
Implementation
SyntheticMouseEvent wrapNativeMouseEvent(MouseEvent nativeEvent) {
return jsifyAndAllowInterop({
// SyntheticEvent fields
'bubbles': nativeEvent.bubbles,
'cancelable': nativeEvent.cancelable,
'currentTarget': nativeEvent.currentTarget,
'defaultPrevented': nativeEvent.defaultPrevented,
'eventPhase': nativeEvent.eventPhase,
'isTrusted': nativeEvent.isTrusted,
'nativeEvent': nativeEvent,
'target': nativeEvent.target,
'timeStamp': nativeEvent.timeStamp,
'type': nativeEvent.type,
// SyntheticEvent methods
'stopPropagation': nativeEvent.stopPropagation,
'preventDefault': nativeEvent.preventDefault,
'persist': () {},
'isPersistent': () => true,
// SyntheticMouseEvent fields
'altKey': nativeEvent.altKey,
'button': nativeEvent.button,
'buttons': nativeEvent.buttons,
'clientX': nativeEvent.client.x,
'clientY': nativeEvent.client.y,
'ctrlKey': nativeEvent.ctrlKey,
'dataTransfer': nativeEvent.dataTransfer,
'metaKey': nativeEvent.metaKey,
'pageX': nativeEvent.page.x,
'pageY': nativeEvent.page.y,
'relatedTarget': nativeEvent.relatedTarget,
'screenX': nativeEvent.screen.x,
'screenY': nativeEvent.screen.y,
'shiftKey': nativeEvent.shiftKey,
}) as SyntheticMouseEvent;
}