From d352658347f82d95653bb31b3c9f45d95d64ca41 Mon Sep 17 00:00:00 2001 From: Stanley Yip Date: Sun, 5 Apr 2020 13:25:25 -0700 Subject: some other changes --- src/client/views/GestureOverlay.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx index 68f1d13fb..9075f8bfa 100644 --- a/src/client/views/GestureOverlay.tsx +++ b/src/client/views/GestureOverlay.tsx @@ -193,7 +193,7 @@ export default class GestureOverlay extends Touchable { }, (500)); } else { - clearTimeout(this._holdTimer); + this._holdTimer && clearTimeout(this._holdTimer); } document.removeEventListener("touchmove", this.onReactTouchMove); document.removeEventListener("touchend", this.onReactTouchEnd); @@ -270,7 +270,7 @@ export default class GestureOverlay extends Touchable { onReactTouchMove = (e: TouchEvent) => { const nts: any = this.getNewTouches(e); - clearTimeout(this._holdTimer); + this._holdTimer && clearTimeout(this._holdTimer); this._holdTimer = undefined; document.dispatchEvent( @@ -290,7 +290,7 @@ export default class GestureOverlay extends Touchable { onReactTouchEnd = (e: TouchEvent) => { const nts: any = this.getNewTouches(e); - clearTimeout(this._holdTimer); + this._holdTimer && clearTimeout(this._holdTimer); this._holdTimer = undefined; document.dispatchEvent( @@ -323,7 +323,7 @@ export default class GestureOverlay extends Touchable { } handleHandDown = async (e: React.TouchEvent) => { - clearTimeout(this._holdTimer!); + this._holdTimer && clearTimeout(this._holdTimer); const fingers = new Array(); for (let i = 0; i < e.touches.length; i++) { const pt: any = e.touches.item(i); -- cgit v1.2.3-70-g09d2 From 43b241a496d446e7b613ad65fb016405009dd532 Mon Sep 17 00:00:00 2001 From: Stanley Yip Date: Sun, 5 Apr 2020 13:31:24 -0700 Subject: Fixed docview bugs --- src/client/views/GestureOverlay.tsx | 6 +++--- src/client/views/nodes/DocumentView.tsx | 31 +++++++++++++++++-------------- 2 files changed, 20 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx index 9075f8bfa..a490491ab 100644 --- a/src/client/views/GestureOverlay.tsx +++ b/src/client/views/GestureOverlay.tsx @@ -623,7 +623,7 @@ export default class GestureOverlay extends Touchable { actionPerformed = true; break; case GestureUtils.Gestures.EndBracket: - this.dispatchGesture(GestureUtils.Gestures.EndBracket); + this.dispatchGesture("endbracket"); actionPerformed = true; break; case GestureUtils.Gestures.Line: @@ -648,7 +648,7 @@ export default class GestureOverlay extends Touchable { document.removeEventListener("pointerup", this.onPointerUp); } - dispatchGesture = (gesture: GestureUtils.Gestures, stroke?: InkData, data?: any) => { + dispatchGesture = (gesture: "box" | "line" | "startbracket" | "endbracket" | "stroke" | "scribble" | "text", stroke?: InkData, data?: any) => { const target = document.elementFromPoint((stroke ?? this._points)[0].X, (stroke ?? this._points)[0].Y); target?.dispatchEvent( new CustomEvent("dashOnGesture", @@ -656,7 +656,7 @@ export default class GestureOverlay extends Touchable { bubbles: true, detail: { points: stroke ?? this._points, - gesture: gesture, + gesture: gesture as any, bounds: this.getBounds(stroke ?? this._points), text: data } diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index aa3c1b3a2..7f2b9ed13 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -670,20 +670,23 @@ export class DocumentView extends DocComponent(Docu } @action - onContextMenu = async (e: React.MouseEvent): Promise => { + onContextMenu = async (e: React.MouseEvent | Touch): Promise => { // the touch onContextMenu is button 0, the pointer onContextMenu is button 2 - if (e.button === 0 && !e.ctrlKey) { - e.preventDefault(); - return; - } - e.persist(); - e?.stopPropagation(); - if (Math.abs(this._downX - e.clientX) > 3 || Math.abs(this._downY - e.clientY) > 3 || - e.isDefaultPrevented()) { + if (!(e instanceof Touch)) { + if (e.button === 0 && !e.ctrlKey) { + e.preventDefault(); + return; + } + e.persist(); + e?.stopPropagation(); + + if (Math.abs(this._downX - e.clientX) > 3 || Math.abs(this._downY - e.clientY) > 3 || + e.isDefaultPrevented()) { + e.preventDefault(); + return; + } e.preventDefault(); - return; } - e.preventDefault(); const cm = ContextMenu.Instance; const templateDoc = Cast(this.props.Document[StrCast(this.props.Document.layoutKey)], Doc, null); @@ -764,7 +767,7 @@ export class DocumentView extends DocComponent(Docu recommender_subitems.push({ description: "Internal recommendations", - event: () => this.recommender(e), + event: () => this.recommender(), icon: "brain" }); @@ -825,7 +828,7 @@ export class DocumentView extends DocComponent(Docu icon: "external-link-alt" }); - if (!this.topMost) { + if (!this.topMost && !(e instanceof Touch)) { // DocumentViews should stop propagation of this event e.stopPropagation(); } @@ -843,7 +846,7 @@ export class DocumentView extends DocComponent(Docu }); } - recommender = async (e: React.MouseEvent) => { + recommender = async () => { if (!ClientRecommender.Instance) new ClientRecommender({ title: "Client Recommender" }); const documents: Doc[] = []; const allDocs = await SearchUtil.GetAllDocs(); -- cgit v1.2.3-70-g09d2