aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/global/globalScripts.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-04-26 01:32:57 -0400
committerbobzel <zzzman@gmail.com>2024-04-26 01:32:57 -0400
commitaf67724dc3a1390cd0c2aded4aeda69f948a0f66 (patch)
treecd936a38c9b32b650d42e1871bd025817fd2d111 /src/client/views/global/globalScripts.ts
parent6ddfdb20e6a0b2c896594ad2c20292c6cfea0c1a (diff)
fixed eraser buttons so that you can switch to the previous eraser, then click again to choose a different eraser
Diffstat (limited to 'src/client/views/global/globalScripts.ts')
-rw-r--r--src/client/views/global/globalScripts.ts25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/client/views/global/globalScripts.ts b/src/client/views/global/globalScripts.ts
index 279d3c24c..d565a530b 100644
--- a/src/client/views/global/globalScripts.ts
+++ b/src/client/views/global/globalScripts.ts
@@ -12,7 +12,21 @@ import { ScriptingGlobals } from '../../util/ScriptingGlobals';
import { SelectionManager } from '../../util/SelectionManager';
import { UndoManager, undoable } from '../../util/UndoManager';
import { GestureOverlay } from '../GestureOverlay';
-import { ActiveFillColor, ActiveInkColor, ActiveInkHideTextLabels, ActiveInkWidth, ActiveIsInkMask, ActiveEraserWidth, InkingStroke, SetActiveFillColor, SetActiveInkColor, SetActiveInkHideTextLabels, SetActiveInkWidth, SetActiveIsInkMask, SetEraserWidth } from '../InkingStroke';
+import {
+ ActiveFillColor,
+ ActiveInkColor,
+ ActiveInkHideTextLabels,
+ ActiveInkWidth,
+ ActiveIsInkMask,
+ ActiveEraserWidth,
+ InkingStroke,
+ SetActiveFillColor,
+ SetActiveInkColor,
+ SetActiveInkHideTextLabels,
+ SetActiveInkWidth,
+ SetActiveIsInkMask,
+ SetEraserWidth,
+} from '../InkingStroke';
import { CollectionFreeFormView } from '../collections/collectionFreeForm';
// import { InkTranscription } from '../InkTranscription';
import { DocData } from '../../../fields/DocSymbols';
@@ -323,6 +337,9 @@ function setActiveTool(tool: InkTool | GestureUtils.Gestures, keepPrim: boolean,
GestureOverlay.Instance.InkShape = tool as GestureUtils.Gestures;
}
} else if (tool) {
+ if ([InkTool.StrokeEraser, InkTool.RadiusEraser, InkTool.SegmentEraser].includes(tool as any)) {
+ Doc.UserDoc().activeEraserTool = tool;
+ }
// pen or eraser
if (Doc.ActiveTool === tool && !GestureOverlay.Instance.InkShape && !keepPrim) {
Doc.ActiveTool = InkTool.None;
@@ -338,6 +355,10 @@ function setActiveTool(tool: InkTool | GestureUtils.Gestures, keepPrim: boolean,
ScriptingGlobals.add(setActiveTool, 'sets the active ink tool mode');
+ScriptingGlobals.add(function activeEraserTool() {
+ return StrCast(Doc.UserDoc().activeEraserTool, InkTool.StrokeEraser);
+}, 'returns the current eraser tool');
+
// ScriptingGlobals.add(function setEraserProperty(option: 'eraseWidth', value: any, checkResult?: boolean) {
// setInk: (doc: Doc) => (doc[DocData].eraserWidth = NumCast(value))
// InkingStroke.setEraserRadius(NumCast(value));
@@ -347,7 +368,7 @@ ScriptingGlobals.add(setActiveTool, 'sets the active ink tool mode');
ScriptingGlobals.add(function setInkProperty(option: 'inkMask' | 'labels' | 'fillColor' | 'strokeWidth' | 'strokeColor' | 'eraserWidth', value: any, checkResult?: boolean) {
const selected = SelectionManager.Docs.lastElement() ?? Doc.UserDoc();
if (option === 'eraserWidth') {
- console.log('eraserWidth', value)
+ console.log('eraserWidth', value);
}
// prettier-ignore
const map: Map<'inkMask' | 'labels' | 'fillColor' | 'strokeWidth' | 'strokeColor' | 'eraserWidth', { checkResult: () => any; setInk: (doc: Doc) => void; setMode: () => void }> = new Map([