Skip to content

Commit 045fa24

Browse files
committed
fix: polygon nested interaction issues
- Prevent hover handles on existing polygons while placing new one - Allow right-click to remove points when placing inside other annotations - Clear stale activeState on all widgets when placing polygon loses focus - Add hasFocus check to RulerWidget (used by RectangleWidget)
1 parent 1fda969 commit 045fa24

File tree

4 files changed

+209
-308
lines changed

4 files changed

+209
-308
lines changed

src/components/tools/AnnotationInfo.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { useElementSize } from '@vueuse/core';
44
import { AnnotationToolStore } from '@/src/store/tools/useAnnotationTool';
55
import { OverlayInfo } from '@/src/composables/annotationTool';
66
7-
// These seem to work ¯\_(ツ)_/¯
87
const TOOLTIP_PADDING_X = 30;
9-
const TOOLTIP_PADDING_Y = 10;
8+
const TOOLTIP_PADDING_Y = 16;
109
1110
const props = defineProps<{
1211
info: OverlayInfo;
@@ -78,6 +77,7 @@ const offset = computed(() => {
7877
background: rgba(255, 255, 255, 0.9) !important;
7978
padding-left: 0;
8079
padding-right: 0;
80+
pointer-events: none;
8181
}
8282
8383
.tooltip-text {

src/vtk/PolygonWidget/behavior.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ export default function widgetBehavior(publicAPI: any, model: any) {
480480
model.hasFocus = false;
481481
if (hadFocus) {
482482
model._widgetManager.releaseFocus();
483+
// Deactivate all widgets so stale activeStates don't persist
484+
// (user may right-click again without moving mouse)
485+
model._widgetManager
486+
.getWidgets()
487+
.forEach((w: any) => w.deactivateAllHandles());
483488
}
484489
model._widgetManager.enablePicking();
485490
};

src/vtk/RulerWidget/behavior.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ export default function widgetBehavior(publicAPI: any, model: any) {
185185
}
186186

187187
// Don't emit hover events if another widget has focus (e.g., is placing)
188-
const activeWidget = model._widgetManager.getActiveWidget();
189-
if (activeWidget && activeWidget !== publicAPI) {
188+
const widgets = model._widgetManager.getWidgets();
189+
const anotherWidgetHasFocus = widgets.some(
190+
(w: any) => w !== publicAPI && w.hasFocus()
191+
);
192+
if (anotherWidgetHasFocus) {
190193
publicAPI.invokeHoverEvent({
191194
...eventData,
192195
hovering: false,
@@ -232,8 +235,11 @@ export default function widgetBehavior(publicAPI: any, model: any) {
232235
}
233236

234237
// If another widget has focus (e.g., is placing), don't show context menu
235-
const activeWidget = model._widgetManager.getActiveWidget();
236-
if (activeWidget && activeWidget !== publicAPI) {
238+
const widgets = model._widgetManager.getWidgets();
239+
const anotherWidgetHasFocus = widgets.some(
240+
(w: any) => w !== publicAPI && w.hasFocus()
241+
);
242+
if (anotherWidgetHasFocus) {
237243
return macro.VOID;
238244
}
239245

0 commit comments

Comments
 (0)