From af1ed62f29df0b72b6d5e0ce968ea8c81bebeca3 Mon Sep 17 00:00:00 2001 From: Forrest Date: Fri, 10 Jan 2025 17:53:17 -0500 Subject: [PATCH] fix(WidgetManager): cross-renderer widget usage Widgets should not remain in an active state if interaction occurs outside of the containing renderer. --- Sources/Widgets/Core/WidgetManager/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sources/Widgets/Core/WidgetManager/index.js b/Sources/Widgets/Core/WidgetManager/index.js index 7b720a06759..a9b435fbc64 100644 --- a/Sources/Widgets/Core/WidgetManager/index.js +++ b/Sources/Widgets/Core/WidgetManager/index.js @@ -183,6 +183,17 @@ function vtkWidgetManager(publicAPI, model) { } } + const deactivateAllWidgets = () => { + let wantRender = false; + for (let i = 0; i < model.widgets.length; i++) { + const w = model.widgets[i]; + wantRender ||= !!w.getActiveState(); + w.deactivateAllHandles(); + } + + if (wantRender) model._interactor.render(); + }; + const handleEvent = async (callData, fromTouchEvent = false) => { if ( !model.isAnimating && @@ -192,6 +203,8 @@ function vtkWidgetManager(publicAPI, model) { const callID = Symbol('UpdateSelection'); model._currentUpdateSelectionCallID = callID; await updateSelection(callData, fromTouchEvent, callID); + } else { + deactivateAllWidgets(); } };