aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-09-14 19:13:34 -0400
committerbobzel <zzzman@gmail.com>2021-09-14 19:13:34 -0400
commit7ab2011d3b6bb7bb2e945265d4ff97983a5a1f38 (patch)
tree628972792123069b9272e9483e76926d725c2561 /src
parentf4b3781cf2250477482d8260e7137d9cbdfcb8e4 (diff)
fixed right-click context menu for Windows.
Diffstat (limited to 'src')
-rw-r--r--src/Utils.ts30
-rw-r--r--src/client/views/nodes/DocumentView.tsx9
2 files changed, 24 insertions, 15 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index ddc16dceb..6eacd8296 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -552,19 +552,23 @@ export function simulateMouseClick(element: Element | null | undefined, x: numbe
screenY: sy,
})));
- rightClick && element.dispatchEvent(
- new MouseEvent("contextmenu", {
- view: window,
- bubbles: true,
- cancelable: true,
- button: 2,
- clientX: x,
- clientY: y,
- movementX: 0,
- movementY: 0,
- screenX: sx,
- screenY: sy,
- }));
+ if (rightClick) {
+ const me =
+ new MouseEvent("contextmenu", {
+ view: window,
+ bubbles: true,
+ cancelable: true,
+ button: 2,
+ clientX: x,
+ clientY: y,
+ movementX: 0,
+ movementY: 0,
+ screenX: sx,
+ screenY: sy,
+ });
+ (me as any).dash = true;
+ element.dispatchEvent(me);
+ }
}
export function lightOrDark(color: any) {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 5ef49bd3b..b680fcf3b 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -672,7 +672,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
const cm = ContextMenu.Instance;
if (!cm || (e as any)?.nativeEvent?.SchemaHandled) return;
- if (e?.buttons === 2) {
+ if (e && !(e.nativeEvent as any).dash) {
const onDisplay = () => setTimeout(() => {
DocumentViewInternal.SelectAfterContextMenu && !this.props.isSelected(true) && SelectionManager.SelectView(this.props.DocumentView(), false); // on a mac, the context menu is triggered on mouse down, but a YouTube video becaomes interactive when selected which means that the context menu won't show up. by delaying the selection until hopefully after the pointer up, the context menu will appear.
setTimeout(() => {
@@ -680,7 +680,12 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
simulateMouseClick(ele, e.clientX, e.clientY, e.screenX, e.screenY);
});
});
- cm.displayMenu((e?.pageX || pageX || 0) - 15, (e?.pageY || pageY || 0) - 15, undefined, undefined, onDisplay);
+ if (navigator.userAgent.includes("Macintosh")) {
+ cm.displayMenu((e?.pageX || pageX || 0) - 15, (e?.pageY || pageY || 0) - 15, undefined, undefined, onDisplay);
+ }
+ else {
+ onDisplay();
+ }
return;
}