aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2020-04-19 00:30:23 -0400
committerBob Zeleznik <zzzman@gmail.com>2020-04-19 00:30:23 -0400
commit34ee553af7b2133632b66f966c07fd1bb1085e81 (patch)
treea506ec6c7a4d1436d88b1a980be5d5817a85515e /src/Utils.ts
parentb7c1c6890c9186578ce06e8c31cdd82662d1c934 (diff)
changed tree view to show context menu icon to avoid right-clicking
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 58f272ba5..9acdc8731 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -470,6 +470,35 @@ export function clearStyleSheetRules(sheet: any) {
return false;
}
+export function simulateMouseClick(element: Element, x: number, y: number, sx: number, sy: number) {
+ ["pointerdown", "pointerup"].map(event => element.dispatchEvent(
+ new PointerEvent(event, {
+ view: window,
+ bubbles: true,
+ cancelable: true,
+ button: 2,
+ pointerType: "mouse",
+ clientX: x,
+ clientY: y,
+ screenX: sx,
+ screenY: sy,
+ })));
+
+ 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,
+ }));
+}
+
export function setupMoveUpEvents(
target: object,
e: React.PointerEvent,