aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-06-29 03:05:29 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-06-29 03:05:29 -0400
commit5cfd32830586a3e1162ee81538e13d675edb79a7 (patch)
treeaeb8332fa93adaa5808afaa7a546618e705f56a3 /src
parent642d22526d102198ed624a2b1e2eaed3b8f731b6 (diff)
keyhandler fixes and global pointer down in mainview
Diffstat (limited to 'src')
-rw-r--r--src/client/views/GlobalKeyHandler.ts14
-rw-r--r--src/client/views/MainView.tsx15
2 files changed, 21 insertions, 8 deletions
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<Doc>) {
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<{}>) {