aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/GlobalKeyHandler.ts
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-07-23 11:38:10 -0400
committerab <abdullah_ahmed@brown.edu>2019-07-23 11:38:10 -0400
commit13c016d7f7765acda7f6ce2d69c14597469f55d7 (patch)
tree6fcf409ee4f0035443aa4fb67a05d24aae09689d /src/client/views/GlobalKeyHandler.ts
parentbd841fe56540e1a9177d2872310b10fefcb4acd1 (diff)
parentd880e4b2fcb4e7bab3ee25d63209b173efcf37c0 (diff)
merged
Diffstat (limited to 'src/client/views/GlobalKeyHandler.ts')
-rw-r--r--src/client/views/GlobalKeyHandler.ts39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index 0d95bb96c..e8a588e58 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -4,9 +4,10 @@ import { CollectionDockingView } from "./collections/CollectionDockingView";
import { MainView } from "./MainView";
import { DragManager } from "../util/DragManager";
import { action } from "mobx";
+import { Doc } from "../../new_fields/Doc";
const modifiers = ["control", "meta", "shift", "alt"];
-type KeyHandler = (keycode: string) => KeyControlInfo;
+type KeyHandler = (keycode: string, e: KeyboardEvent) => KeyControlInfo;
type KeyControlInfo = {
preventDefault: boolean,
stopPropagation: boolean
@@ -42,7 +43,7 @@ export default class KeyManager {
return;
}
- let control = handleConstrained(keyname);
+ let control = handleConstrained(keyname, e);
control.stopPropagation && e.stopPropagation();
control.preventDefault && e.preventDefault();
@@ -53,7 +54,7 @@ export default class KeyManager {
}
});
- private unmodified = action((keyname: string) => {
+ private unmodified = action((keyname: string, e: KeyboardEvent) => {
switch (keyname) {
case "escape":
if (MainView.Instance.isPointerDown) {
@@ -69,11 +70,21 @@ export default class KeyManager {
break;
case "delete":
case "backspace":
- SelectionManager.SelectedDocuments().map(docView => {
- let doc = docView.props.Document;
- let remove = docView.props.removeDocument;
- remove && remove(doc);
- });
+ if (document.activeElement) {
+ if (document.activeElement.tagName === "INPUT" || document.activeElement.tagName === "TEXTAREA") {
+ return { stopPropagation: false, preventDefault: false };
+ }
+ }
+ UndoManager.RunInBatch(() => {
+ SelectionManager.SelectedDocuments().map(docView => {
+ let doc = docView.props.Document;
+ let remove = docView.props.removeDocument;
+ remove && remove(doc);
+ });
+ }, "delete");
+ break;
+ case "enter":
+ SelectionManager.SelectedDocuments().map(selected => Doc.ToggleDetailLayout(selected.props.Document));
break;
}
@@ -100,15 +111,25 @@ export default class KeyManager {
};
});
- private ctrl = action((keyname: string) => {
+ private ctrl = action((keyname: string, e: KeyboardEvent) => {
let stopPropagation = true;
let preventDefault = true;
switch (keyname) {
case "arrowright":
+ if (document.activeElement) {
+ if (document.activeElement.tagName === "INPUT" || document.activeElement.tagName === "TEXTAREA") {
+ return { stopPropagation: false, preventDefault: false };
+ }
+ }
MainView.Instance.mainFreeform && CollectionDockingView.Instance.AddRightSplit(MainView.Instance.mainFreeform, undefined);
break;
case "arrowleft":
+ if (document.activeElement) {
+ if (document.activeElement.tagName === "INPUT" || document.activeElement.tagName === "TEXTAREA") {
+ return { stopPropagation: false, preventDefault: false };
+ }
+ }
MainView.Instance.mainFreeform && CollectionDockingView.Instance.CloseRightSplit(MainView.Instance.mainFreeform);
break;
case "f":