aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/ContextMenu.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-09-17 02:14:31 -0400
committerbobzel <zzzman@gmail.com>2021-09-17 02:14:31 -0400
commitf5c4aa829955467c37ff35fb47b6d3c47fef4590 (patch)
treee7e1726781fd1002c57900e9bb86864881ead277 /src/client/views/ContextMenu.tsx
parent1de71a39f1f6ebc2c909c92694db340cc9b256a0 (diff)
fixed right-drag marquee on webBox on Mac
Diffstat (limited to 'src/client/views/ContextMenu.tsx')
-rw-r--r--src/client/views/ContextMenu.tsx20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/client/views/ContextMenu.tsx b/src/client/views/ContextMenu.tsx
index 78564a11b..80ff16cf9 100644
--- a/src/client/views/ContextMenu.tsx
+++ b/src/client/views/ContextMenu.tsx
@@ -26,8 +26,7 @@ export class ContextMenu extends React.Component {
@observable private _mouseX: number = -1;
@observable private _mouseY: number = -1;
@observable private _shouldDisplay: boolean = false;
- @observable private _mouseDown: boolean = false;
-
+ private _ignoreUp = false;
private _reactionDisposer?: IReactionDisposer;
constructor(props: Readonly<{}>) {
@@ -36,17 +35,23 @@ export class ContextMenu extends React.Component {
ContextMenu.Instance = this;
}
+ public setIgnoreEvents(ignore: boolean) {
+ this._ignoreUp = ignore;
+ }
+
@action
onPointerDown = (e: PointerEvent) => {
- this._mouseDown = true;
this._mouseX = e.clientX;
this._mouseY = e.clientY;
}
@action
onPointerUp = (e: PointerEvent) => {
- this._mouseDown = false;
const curX = e.clientX;
const curY = e.clientY;
+ if (this._ignoreUp) {
+ this._ignoreUp = false;
+ return;
+ }
if (Math.abs(this._mouseX - curX) > 1 || Math.abs(this._mouseY - curY) > 1) {
this._shouldDisplay = false;
}
@@ -62,7 +67,7 @@ export class ContextMenu extends React.Component {
componentWillUnmount() {
document.removeEventListener("pointerdown", this.onPointerDown);
document.removeEventListener("pointerup", this.onPointerUp);
- this._reactionDisposer && this._reactionDisposer();
+ this._reactionDisposer?.();
}
@action
@@ -70,10 +75,6 @@ export class ContextMenu extends React.Component {
document.addEventListener("pointerdown", this.onPointerDown);
document.addEventListener("pointerup", this.onPointerUp);
- this._reactionDisposer = reaction(
- () => this._shouldDisplay,
- () => this._shouldDisplay && !this._mouseDown && runInAction(() => this._display = true)
- );
}
@action
@@ -156,6 +157,7 @@ export class ContextMenu extends React.Component {
this._searchString = initSearch;
this._shouldDisplay = true;
this._onDisplay = onDisplay;
+ this._display = !onDisplay;
}
@action