MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / onPointerDown

Function onPointerDown

frontend/src/utility-functions/input.ts:129–157  ·  view source on GitHub ↗
(e: PointerEvent, editor: EditorWrapper, dialogStore: DialogStore)

Source from the content-addressed store, hash-verified

127}
128
129export 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
159export function onPointerUp(e: PointerEvent, editor: EditorWrapper) {
160 potentiallyRestoreCanvasFocus(e);

Callers 1

input.tsFile · 0.90

Calls 4

textInputCleanupFunction · 0.90
getFunction · 0.70

Tested by

no test coverage detected