@teachinglab/omd 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,71 @@
1
+ import { Tool } from './tool.js';
2
+
3
+ /**
4
+ * Pointer/Browse tool
5
+ * Allows browsing and interacting with interactive components without selecting or moving items.
6
+ * Use this tool to click buttons, interact with UI elements, etc. without modifying the canvas.
7
+ */
8
+ export class PointerTool extends Tool {
9
+ /**
10
+ * @param {OMDCanvas} canvas
11
+ * @param {object} [options={}]
12
+ */
13
+ constructor(canvas, options = {}) {
14
+ super(canvas, { ...options });
15
+
16
+ this.displayName = 'Pointer';
17
+ this.description = 'Browse and interact with components';
18
+ this.icon = 'pointer';
19
+ this.shortcut = 'V';
20
+ this.category = 'navigation';
21
+ }
22
+
23
+ onActivate() {
24
+ this.isActive = true;
25
+ if (this.canvas.cursor) {
26
+ this.canvas.cursor.show();
27
+ this.canvas.cursor.setShape('pointer');
28
+ }
29
+ super.onActivate();
30
+ }
31
+
32
+ onDeactivate() {
33
+ this.isActive = false;
34
+ super.onDeactivate();
35
+ }
36
+
37
+ onPointerDown(event) {
38
+ // Pointer tool is completely passive - it does nothing
39
+ // This allows click events to pass through to interactive components
40
+ // but prevents any canvas manipulation (drawing, selecting, moving)
41
+
42
+ // Explicitly ensure we are not entering a drawing/dragging state
43
+ if (this.canvas?.eventManager) {
44
+ this.canvas.eventManager.isDrawing = false;
45
+ }
46
+ }
47
+
48
+ onPointerMove(event) {
49
+ // No-op: allow hovering without any interaction
50
+ }
51
+
52
+ onPointerUp(event) {
53
+ // No-op: do not modify selections or positions
54
+ }
55
+
56
+ onKeyboardShortcut(key, event) {
57
+ // No shortcuts to handle for passive pointer tool
58
+ return false;
59
+ }
60
+
61
+ onKeyboardShortcut(key, event) {
62
+ // No shortcuts to handle for passive pointer tool
63
+ return false;
64
+ }
65
+
66
+ getCursor() {
67
+ return 'pointer';
68
+ }
69
+ }
70
+
71
+