(
target,
defaultPayload,
{pointerType = 'mouse', modified} = {},
)
| 108 | */ |
| 109 | |
| 110 | export function contextmenu( |
| 111 | target, |
| 112 | defaultPayload, |
| 113 | {pointerType = 'mouse', modified} = {}, |
| 114 | ) { |
| 115 | const dispatch = arg => target.dispatchEvent(arg); |
| 116 | |
| 117 | const payload = { |
| 118 | pointerId: defaultPointerId, |
| 119 | pointerType, |
| 120 | ...defaultPayload, |
| 121 | }; |
| 122 | |
| 123 | const preventDefault = payload.preventDefault; |
| 124 | |
| 125 | if (pointerType === 'touch') { |
| 126 | if (hasPointerEvent()) { |
| 127 | dispatch( |
| 128 | domEvents.pointerdown({ |
| 129 | ...payload, |
| 130 | button: buttonType.primary, |
| 131 | buttons: buttonsType.primary, |
| 132 | }), |
| 133 | ); |
| 134 | } |
| 135 | const touch = createTouch(target, payload); |
| 136 | touchStore.addTouch(touch); |
| 137 | const touchEventPayload = createTouchEventPayload(target, touch, payload); |
| 138 | dispatch(domEvents.touchstart(touchEventPayload)); |
| 139 | dispatch( |
| 140 | domEvents.contextmenu({ |
| 141 | button: buttonType.primary, |
| 142 | buttons: buttonsType.none, |
| 143 | preventDefault, |
| 144 | }), |
| 145 | ); |
| 146 | touchStore.removeTouch(touch); |
| 147 | } else if (pointerType === 'mouse') { |
| 148 | if (modified === true) { |
| 149 | const button = buttonType.primary; |
| 150 | const buttons = buttonsType.primary; |
| 151 | const ctrlKey = true; |
| 152 | if (hasPointerEvent()) { |
| 153 | dispatch( |
| 154 | domEvents.pointerdown({button, buttons, ctrlKey, pointerType}), |
| 155 | ); |
| 156 | } |
| 157 | dispatch(domEvents.mousedown({button, buttons, ctrlKey})); |
| 158 | if (platform.get() === 'mac') { |
| 159 | dispatch( |
| 160 | domEvents.contextmenu({button, buttons, ctrlKey, preventDefault}), |
| 161 | ); |
| 162 | } |
| 163 | } else { |
| 164 | const button = buttonType.secondary; |
| 165 | const buttons = buttonsType.secondary; |
| 166 | if (hasPointerEvent()) { |
| 167 | dispatch(domEvents.pointerdown({button, buttons, pointerType})); |
nothing calls this directly
no test coverage detected