diff --git a/CHANGELOG.md b/CHANGELOG.md index eab470de..46972777 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ > - Bugfixes: > - Fixed an issue where connections would not gain focus when selected, which could prevent editor keybindings from functioning in certain scenarios > - Resolved an issue where selecting a node did not deselect connections and vice versa +> - Fixed a bug preventing ItemContainers from being dragged when the mouse could not be captured #### **Version 7.0.0** diff --git a/Nodify/Containers/States/Default.cs b/Nodify/Containers/States/Default.cs index e1fa0adf..9c2f15bb 100644 --- a/Nodify/Containers/States/Default.cs +++ b/Nodify/Containers/States/Default.cs @@ -37,7 +37,7 @@ public override void Enter(IInputElementState? from) protected override void OnMouseDown(MouseButtonEventArgs e) { - if (!IsSelectable(e)) + if (!Element.IsSelectableLocation(e.GetPosition(Element))) { return; } @@ -45,7 +45,7 @@ protected override void OnMouseDown(MouseButtonEventArgs e) EditorGestures.ItemContainerGestures gestures = EditorGestures.Mappings.ItemContainer; if (gestures.Drag.Matches(e.Source, e)) { - _isDragging = Element.IsDraggable && CaptureMouseSafe(); + _isDragging = Element.IsDraggable; } if (gestures.Selection.Select.Matches(e.Source, e)) @@ -63,8 +63,8 @@ protected override void OnMouseDown(MouseButtonEventArgs e) if (_isDragging || _selectionType.HasValue) { - Element.Focus(); e.Handled = true; + CaptureMouseSafe(); } } @@ -107,31 +107,14 @@ protected override void OnMouseUp(MouseButtonEventArgs e) _selectionType = null; } - private bool IsSelectable(MouseButtonEventArgs e) - { - if (!Element.IsSelectableLocation(e.GetPosition(Element))) - { - return false; - } - - if (Mouse.Captured != null && !Element.IsMouseCaptured) - { - return false; - } - - return true; - } - - private bool CaptureMouseSafe() + private void CaptureMouseSafe() { // Avoid stealing mouse capture from other elements if (Mouse.Captured == null || Element.IsMouseCaptured) { + Element.Focus(); Element.CaptureMouse(); - return true; } - - return false; } private static SelectionType GetSelectionTypeForDragging(SelectionType? selectionType)