(e: PointerEvent, editor: EditorWrapper, dialogStore: DialogStore)
| 127 | } |
| 128 | |
| 129 | export function onPointerDown(e: PointerEvent, editor: EditorWrapper, dialogStore: DialogStore) { |
| 130 | potentiallyRestoreCanvasFocus(e); |
| 131 | |
| 132 | const inFloatingMenu = e.target instanceof Element && e.target.closest("[data-floating-menu-content]"); |
| 133 | const isTargetingCanvas = !inFloatingMenu && e.target instanceof Element && e.target.closest("[data-viewport], [data-viewport-container], [data-node-graph]"); |
| 134 | const inDialog = e.target instanceof Element && e.target.closest("[data-dialog] [data-floating-menu-content]"); |
| 135 | const inContextMenu = e.target instanceof Element && e.target.closest("[data-context-menu]"); |
| 136 | const inTextInput = e.target === textToolInteractiveInputElement; |
| 137 | |
| 138 | if (get(dialogStore).visible && !inDialog) { |
| 139 | editor.onDialogDismiss(); |
| 140 | e.preventDefault(); |
| 141 | e.stopPropagation(); |
| 142 | } |
| 143 | |
| 144 | if (!inTextInput && !inContextMenu) { |
| 145 | if (textToolInteractiveInputElement) { |
| 146 | const isLeftOrRightClick = e.button === BUTTON_RIGHT || e.button === BUTTON_LEFT; |
| 147 | editor.onChangeText(textInputCleanup(textToolInteractiveInputElement.innerText), isLeftOrRightClick); |
| 148 | } else { |
| 149 | viewportPointerInteractionOngoing = isTargetingCanvas instanceof Element; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if (viewportPointerInteractionOngoing && isTargetingCanvas instanceof Element) { |
| 154 | const modifiers = makeKeyboardModifiersBitfield(e); |
| 155 | editor.onMouseDown(e.clientX, e.clientY, e.buttons, modifiers); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | export function onPointerUp(e: PointerEvent, editor: EditorWrapper) { |
| 160 | potentiallyRestoreCanvasFocus(e); |
no test coverage detected