From 35a68e69f6a995496a090a1e2291a9f18387411f Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 10 May 2022 16:09:04 -0400 Subject: fixed shift-clicking to add to doc decorations selection --- src/client/views/DocumentDecorations.tsx | 5 ++--- src/client/views/GlobalKeyHandler.ts | 19 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 936946df0..19119bb56 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -49,7 +49,7 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number, P @observable private _titleControlString: string = "#title"; @observable private _edtingTitle = false; @observable private _hidden = false; - + @observable public AddToSelection = false; // if Shift is pressed, then this should be set so that clicking on the selection background is ignored so overlapped documents can be added to the selection set. @observable public Interacting = false; @observable public pushIcon: IconProp = "arrow-alt-circle-up"; @observable public pullIcon: IconProp = "arrow-alt-circle-down"; @@ -527,7 +527,6 @@ export class DocumentDecorations extends React.Component<{ PanelWidth: number, P const resizerScheme = colorScheme ? "documentDecorations-resizer" + colorScheme : ""; const rotation = NumCast(seldoc.rootDoc._jitterRotation); - const rdeg = rotation / 180 * Math.PI; return (
{ e.preventDefault(); e.stopPropagation(); }} /> {bounds.r - bounds.x < 15 && bounds.b - bounds.y < 15 ? (null) : <> diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts index 914802041..767efdbc2 100644 --- a/src/client/views/GlobalKeyHandler.ts +++ b/src/client/views/GlobalKeyHandler.ts @@ -1,5 +1,5 @@ import { random } from "lodash"; -import { action, observable } from "mobx"; +import { action, observable, runInAction } from "mobx"; import { DateField } from "../../fields/DateField"; import { Doc, DocListCast } from "../../fields/Doc"; import { Id } from "../../fields/FieldSymbols"; @@ -30,7 +30,7 @@ import { DocumentLinksButton } from "./nodes/DocumentLinksButton"; import { AnchorMenu } from "./pdf/AnchorMenu"; const modifiers = ["control", "meta", "shift", "alt"]; -type KeyHandler = (keycode: string, e: KeyboardEvent) => KeyControlInfo | Promise; +type KeyHandler = (keycode: string, e: KeyboardEvent) => KeyControlInfo; type KeyControlInfo = { preventDefault: boolean, stopPropagation: boolean @@ -39,7 +39,6 @@ type KeyControlInfo = { export class KeyManager { public static Instance: KeyManager = new KeyManager(); private router = new Map(); - @observable ShiftPressed = false; constructor() { const isMac = navigator.platform.toLowerCase().indexOf("mac") >= 0; @@ -53,11 +52,11 @@ export class KeyManager { } public unhandle = action((e: KeyboardEvent) => { - if (e.key?.toLowerCase() === "shift") KeyManager.Instance.ShiftPressed = false; + if (e.key?.toLowerCase() === "shift") runInAction(() => DocumentDecorations.Instance.AddToSelection = false); }); - public handle = action(async (e: KeyboardEvent) => { - if (e.key?.toLowerCase() === "shift" && e.ctrlKey && e.altKey) KeyManager.Instance.ShiftPressed = true; + public handle = action((e: KeyboardEvent) => { + if (e.key?.toLowerCase() === "shift") DocumentDecorations.Instance.AddToSelection = true; //if (!Doc.UserDoc().noviceMode && e.key.toLocaleLowerCase() === "shift") DocServer.UPDATE_SERVER_CACHE(true); const keyname = e.key && e.key.toLowerCase(); this.handleGreedy(keyname); @@ -74,7 +73,7 @@ export class KeyManager { return; } - const control = await handleConstrained(keyname, e); + const control = handleConstrained(keyname, e); control.stopPropagation && e.stopPropagation(); control.preventDefault && e.preventDefault(); @@ -173,7 +172,7 @@ export class KeyManager { }; }); - private shift = action(async (keyname: string) => { + private shift = action((keyname: string) => { const stopPropagation = false; const preventDefault = false; @@ -334,9 +333,7 @@ export class KeyManager { } } - async printClipboard() { - const text: string = await navigator.clipboard.readText(); - } + getClipboard() { return navigator.clipboard.readText(); } private ctrl_shift = action((keyname: string) => { const stopPropagation = true; -- cgit v1.2.3-70-g09d2