(e: MouseEvent, editor: EditorWrapper)
| 176 | // Mouse events |
| 177 | |
| 178 | export function onPotentialDoubleClick(e: MouseEvent, editor: EditorWrapper) { |
| 179 | if (textToolInteractiveInputElement || inPointerLock) return; |
| 180 | |
| 181 | // Allow only events within the viewport or node graph boundaries |
| 182 | const isTargetingCanvas = e.target instanceof Element && e.target.closest("[data-viewport], [data-viewport-container], [data-node-graph]"); |
| 183 | if (!(isTargetingCanvas instanceof Element)) return; |
| 184 | |
| 185 | // Allow only repeated increments of double-clicks (not 1, 3, 5, etc.) |
| 186 | if (e.detail % 2 == 1) return; |
| 187 | |
| 188 | // `e.buttons` is always 0 in the `mouseup` event, so we have to convert from `e.button` instead |
| 189 | let buttons = 1; |
| 190 | if (e.button === BUTTON_LEFT) buttons = 1; // Left |
| 191 | if (e.button === BUTTON_RIGHT) buttons = 2; // Right |
| 192 | if (e.button === BUTTON_MIDDLE) buttons = 4; // Middle |
| 193 | if (e.button === BUTTON_BACK) buttons = 8; // Back |
| 194 | if (e.button === BUTTON_FORWARD) buttons = 16; // Forward |
| 195 | |
| 196 | const modifiers = makeKeyboardModifiersBitfield(e); |
| 197 | editor.onDoubleClick(e.clientX, e.clientY, buttons, modifiers); |
| 198 | } |
| 199 | |
| 200 | export function onMouseDown(e: MouseEvent) { |
| 201 | // Block middle mouse button auto-scroll mode (the circular gizmo that appears and allows quick scrolling by moving the cursor above or below it) |
no test coverage detected