From 5cfd32830586a3e1162ee81538e13d675edb79a7 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sat, 29 Jun 2019 03:05:29 -0400 Subject: keyhandler fixes and global pointer down in mainview --- src/client/views/GlobalKeyHandler.ts | 14 +++++++++----- src/client/views/MainView.tsx | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts index 95a367cea..ac1c33c71 100644 --- a/src/client/views/GlobalKeyHandler.ts +++ b/src/client/views/GlobalKeyHandler.ts @@ -4,7 +4,6 @@ import { CollectionDockingView } from "./collections/CollectionDockingView"; import { MainView } from "./MainView"; import { DragManager } from "../util/DragManager"; import { action } from "mobx"; -import { emptyFunction } from "../../Utils"; const modifiers = ["control", "meta", "shift", "alt"]; type KeyHandler = (keycode: string) => KeyControlInfo; @@ -23,6 +22,8 @@ export default class KeyManager { let isMac = navigator.platform.toLowerCase().indexOf("mac") >= 0; + // SHIFT CONTROL ALT META + this.router.set("0000", this.unmodified); this.router.set(isMac ? "0001" : "0100", this.ctrl); this.router.set(isMac ? "0100" : "0010", this.alt); @@ -59,12 +60,15 @@ export default class KeyManager { private unmodified = action((keyname: string) => { switch (keyname) { case "escape": - if (CollectionDockingView.Instance.HasFullScreen()) { - CollectionDockingView.Instance.CloseFullScreen(); + if (this.mainView.isPointerDown) { + DragManager.AbortDrag(); } else { - SelectionManager.DeselectAll(); + if (CollectionDockingView.Instance.HasFullScreen()) { + CollectionDockingView.Instance.CloseFullScreen(); + } else { + SelectionManager.DeselectAll(); + } } - DragManager.AbortDrag(); break; } diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 157512aa0..629827f11 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -53,9 +53,7 @@ export class MainView extends React.Component { let docs = DocListCast(this.mainContainer!.data); return (docs && docs.length > 1) ? docs[1] : undefined; } - private globalDisplayFlags = observable({ - jumpToVisible: false - }); + public isPointerDown = false; private set mainContainer(doc: Opt) { if (doc) { if (!("presentationView" in doc)) { @@ -69,10 +67,21 @@ export class MainView extends React.Component { KeyManager.Handler = new KeyManager(this); document.removeEventListener("keydown", KeyManager.Handler.handle); document.addEventListener("keydown", KeyManager.Handler.handle); + + document.removeEventListener("pointerdown", this.pointerDown); + document.addEventListener("pointerdown", this.pointerDown); + + document.removeEventListener("pointerup", this.pointerUp); + document.addEventListener("pointerup", this.pointerUp); } + pointerDown = (e: PointerEvent) => this.isPointerDown = true; + pointerUp = (e: PointerEvent) => this.isPointerDown = false; + componentWillUnMount() { document.removeEventListener("keydown", KeyManager.Handler.handle); + document.removeEventListener("pointerdown", this.pointerDown); + document.removeEventListener("pointerup", this.pointerUp); } constructor(props: Readonly<{}>) { -- cgit v1.2.3-70-g09d2