aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/GlobalKeyHandler.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-11-18 23:47:13 -0500
committerbobzel <zzzman@gmail.com>2023-11-18 23:47:13 -0500
commit2b0e4ccc096998eb1d727f2e85ea8c1a63b27e08 (patch)
tree1d5bc81e4cf74b20b599a5069c3448a2de4784fb /src/client/views/GlobalKeyHandler.ts
parent1b568af6b2725b9eed6f591bfce193d39d5804de (diff)
fixed ctrl-drag for expressions, maps, fform doc selections. fixed using shift to add Doc to a selection and also when bounding box already covers the doc to add. fixed dragging maximize button to start goldenlayout drag properly. fixed typing character to group,etc a multiselection when a text doc has input focus. fixed using clusters. add Shift-U to ungroup alternate group style. multi-select blurs() all active inputs. shift-selecting a multi-selected Doc, deselects it.
Diffstat (limited to 'src/client/views/GlobalKeyHandler.ts')
-rw-r--r--src/client/views/GlobalKeyHandler.ts38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index 13791b763..87f81fe76 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -51,12 +51,18 @@ export class KeyManager {
public unhandle = action((e: KeyboardEvent) => {
e.key === 'Control' && (CtrlKey = false);
- if (e.key?.toLowerCase() === 'shift') runInAction(() => (DocumentDecorations.Instance.AddToSelection = false));
+ });
+ public handleModifiers = action((e: KeyboardEvent) => {
+ if (e.shiftKey) SnappingManager.SetShiftKey(true);
+ if (e.ctrlKey) SnappingManager.SetCtrlKey(true);
+ });
+ public unhandleModifiers = action((e: KeyboardEvent) => {
+ if (!e.shiftKey) SnappingManager.SetShiftKey(false);
+ if (!e.ctrlKey) SnappingManager.SetCtrlKey(false);
});
public handle = action((e: KeyboardEvent) => {
e.key === 'Control' && (CtrlKey = true);
- if (e.key?.toLowerCase() === 'shift') DocumentDecorations.Instance.AddToSelection = true;
//if (!Doc.noviceMode && e.key.toLocaleLowerCase() === "shift") DocServer.UPDATE_SERVER_CACHE(true);
const keyname = e.key && e.key.toLowerCase();
this.handleGreedy(keyname);
@@ -94,28 +100,21 @@ export class KeyManager {
switch (keyname) {
case 'u':
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
- const ungroupings = SelectionManager.Views().slice();
+ const ungroupings = SelectionManager.Views();
UndoManager.RunInBatch(() => ungroupings.map(dv => (dv.layoutDoc.group = undefined)), 'ungroup');
SelectionManager.DeselectAll();
}
break;
case 'g':
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
- const groupings = SelectionManager.Views().slice();
- const randomGroup = random(0, 1000);
- const collectionView = groupings.reduce((col, g) => (col === null || g.CollectionFreeFormView === col ? g.CollectionFreeFormView : undefined), null as null | undefined | CollectionFreeFormView);
+ const selected = SelectionManager.Views();
+ const collectionView = selected.reduce((col, dv) => (col === null || dv.CollectionFreeFormView === col ? dv.CollectionFreeFormView : undefined), null as null | undefined | CollectionFreeFormView);
if (collectionView) {
- UndoManager.RunInBatch(() => {
- collectionView._marqueeViewRef.current?.collection(
- e,
- true,
- groupings.map(g => g.rootDoc)
- );
- }, 'grouping');
+ UndoManager.RunInBatch(() =>
+ collectionView._marqueeViewRef.current?.collection(e, true, SelectionManager.Docs())
+ , 'grouping');
break;
}
- UndoManager.RunInBatch(() => groupings.map(dv => (dv.layoutDoc.group = randomGroup)), 'group');
- SelectionManager.DeselectAll();
}
break;
case ' ':
@@ -183,11 +182,16 @@ export class KeyManager {
case 'arrowright': return this.nudge(10, 0, 'nudge right');
case 'arrowup': return this.nudge(0, -10, 'nudge up');
case 'arrowdown': return this.nudge(0, 10, 'nudge down');
+ case 'u' :
+ if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
+ UndoManager.RunInBatch(() => SelectionManager.Docs().forEach(doc => (doc.group = undefined)), 'unggroup');
+ SelectionManager.DeselectAll();
+ }
+ break;
case 'g':
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
- const groupings = SelectionManager.Views().slice();
const randomGroup = random(0, 1000);
- UndoManager.RunInBatch(() => groupings.map(dv => (dv.layoutDoc.group = randomGroup)), 'group');
+ UndoManager.RunInBatch(() => SelectionManager.Docs().forEach(doc => (doc.group = randomGroup)), 'group');
SelectionManager.DeselectAll();
}
break;