microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.35k stars 304 forks source link

ObjectUnderMouseCursor is set to last node after node is removed #271

Open assafwo1 opened 3 years ago

assafwo1 commented 3 years ago

reproduce steps:

  1. create a new gviewer
  2. hover over gviewer
  3. assert ObjectUnderMouseCursor is null
  4. add a new node
  5. hover over the new node
  6. assert ObjectUnderMouseCursor is the node
  7. remove the node
  8. assert ObjectUnderMouseCursor is null

issue: step 8 fails.

assafwo1 commented 3 years ago
    public IViewerObject ObjectUnderMouseCursor
    {
        get
        {
            // >>>>>>>>>>>>>>>this function can bring a stale object<<<<<<<<<<<<<<<
            var location = Mouse.GetPosition(_graphCanvas);
            if (!(_objectUnderMouseDetectionLocation == location))
                UpdateWithWpfHitObjectUnderMouseOnLocation(location, MyHitTestResultCallbackWithNoCallbacksToTheUser);
            return GetIViewerObjectFromObjectUnderCursor(_objectUnderMouseCursor);
        }
    }
assafwo1 commented 3 years ago

work around: gViewer1.ObjectUnderMouseCursor is Microsoft.Msagl.GraphViewerGdi.DNode // unreliable gViewer1.ObjectUnderMouseCursor is Microsoft.Msagl.GraphViewerGdi.DNode && gViewer1.Graph.NodeCount != 0 // reliable