diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs index 0039a336d97..12beeefc08b 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs @@ -2365,6 +2365,10 @@ private void DynamoView_KeyUp(object sender, KeyEventArgs e) if (dynamoViewModel.BackgroundPreviewViewModel.CanNavigateBackground) { dynamoViewModel.BackgroundPreviewViewModel.NavigationKeyIsDown = false; + // Release any mouse capture held by the 3D preview viewport + // (e.g., during a right-click orbit gesture) so the orbit wheel + // indicator disappears immediately when returning to graph view. + BackgroundPreview?.ReleaseViewportMouseCapture(); dynamoViewModel.EscapeCommand.Execute(null); e.Handled = true; } diff --git a/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml.cs b/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml.cs index e0fb71e17e9..0f14e4584be 100644 --- a/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml.cs @@ -448,6 +448,29 @@ private Point3D GetCameraPosition() { return View.GetCameraPosition(); } + + /// + /// Ends any active HelixToolkit camera gesture (e.g. right-click orbit) and + /// hides the orbit indicator when switching back to graph view. + /// + /// + /// HelixToolkit's MouseGestureHandler has no LostMouseCapture handler, so + /// calling Mouse.Capture(null) alone releases WPF capture but never invokes + /// Completed() / HideTargetAdorner(). Raising a synthetic MouseUp causes + /// HelixToolkit's OnMouseUp to run, which properly ends the gesture. + /// + internal void ReleaseViewportMouseCapture() + { + if (watch_view?.IsMouseCaptureWithin ?? false) + { + Mouse.Capture(null); + var args = new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Right) + { + RoutedEvent = UIElement.MouseUpEvent + }; + watch_view.RaiseEvent(args); + } + } }