Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/DynamoCoreWpf/Views/Core/NodeView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ private void OnNodeViewMouseLeave(object sender, MouseEventArgs e)
ViewModel.ZIndex = oldZIndex;

// If mouse in over node/preview control or preview control is pined, we can not hide preview control.
if (IsMouseOver || PreviewControl.IsMouseOver || PreviewControl.StaysOpen ||
if (IsMouseOver || PreviewControl.IsMouseOver || PreviewControl.StaysOpen || IsMouseInsidePreview(e) ||
(Mouse.Captured is DragCanvas && IsMouseInsideNodeOrPreview(e.GetPosition(this)))) return;

// If it's expanded, then first condense it.
Expand Down Expand Up @@ -633,14 +633,35 @@ private bool IsMouseInsideNodeOrPreview(Point mousePosition)
{
isInside = true;
}

return HitTestFilterBehavior.Stop;
},
ht => HitTestResultBehavior.Stop,
new PointHitTestParameters(mousePosition));
return isInside;
}

/// <summary>
/// Checks whether a mouse event occurred at a position matching the preview.
/// Alternatives attempted:
/// - PreviewControl.IsMouseOver => This is always false
/// - HitTest on NodeView => Anomalous region that skips right part of preview if larger than node
/// - HitTest on Preview => Bounds become irreversible larger than "mouse over area" after preview is expanded
/// </summary>
/// <param name="e">A mouse event</param>
/// <returns>Whether the mouse is over the preview or not</returns>
private bool IsMouseInsidePreview(MouseEventArgs e)
Copy link
Contributor

@aparajit-pratap aparajit-pratap Jul 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this method different in functionality from the method with the similar name: IsMouseInsideNodeOrPreview? Does the latter method address the second point above: HitTest on NodeView => Anomalous region that skips right part of preview if larger than node, and is therefore an insufficient test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right @aparajit-pratap . I know it's kinda strange for a method summary, but why it was needed was hard to explain otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know why the anomalous region exists? 😉 💀

{
var isInside = false;
if (previewControl != null)
{
var bounds = new Rect(0, 0, previewControl.ActualWidth, previewControl.ActualHeight);
var mousePosition = e.GetPosition(previewControl);
isInside = bounds.Contains(mousePosition);
}

return isInside;
}

/// <summary>
/// Enables/disables preview control.
/// </summary>
Expand Down