Skip to content

Commit b1c69c3

Browse files
authored
[ENG-870] Bug fix allow right click on canvas (#577)
* cur progress * manual fix * rebase * use setTimeout because it results in no flicker
1 parent 6c65f20 commit b1c69c3

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

apps/obsidian/src/components/canvas/TldrawViewComponent.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,29 @@ export const TldrawPreviewComponent = ({
270270
// Handle pointer events
271271
if (event.type !== "pointer") return;
272272
const e = event as TLPointerEventInfo;
273+
274+
if (e.type === "pointer" && e.name === "right_click") {
275+
const container = editor.getContainer();
276+
const canvas = container?.querySelector(".tl-canvas") as HTMLElement;
277+
278+
if (canvas) {
279+
setTimeout(() => {
280+
const contextMenuEvent = new MouseEvent("contextmenu", {
281+
bubbles: true,
282+
cancelable: true,
283+
clientX: e.point.x,
284+
clientY: e.point.y,
285+
button: 2,
286+
shiftKey: e.shiftKey,
287+
ctrlKey: e.ctrlKey,
288+
altKey: e.altKey,
289+
metaKey: e.metaKey,
290+
});
291+
canvas.dispatchEvent(contextMenuEvent);
292+
}, 0);
293+
}
294+
}
295+
273296
if (e.type === "pointer" && e.name === "pointer_down") {
274297
const currentTool = editor.getCurrentTool();
275298
const currentToolId = currentTool.id;

0 commit comments

Comments
 (0)