OnEnterLeave problem when deleting link

I use the code below to change the color of the link and its nodes when mouse hoovers on link:

    public override bool OnEnterLeave(GoObject from, GoObject to, GoView view)
        // When on  link
        if (to == this)
            oldPen = this.Pen;
            oldColor = ((GoTextNode)this.ToNode).Shape.BrushColor;
            this.Pen = new Pen(Color.YellowGreen, oldPen.Width);
            this.Pen.DashStyle = oldPen.DashStyle;

            ((GoTextNode)this.FromNode).Shape.BrushColor = Color.YellowGreen;
            ((GoTextNode)this.ToNode).Shape.BrushColor = Color.YellowGreen;
            this.Pen = oldPen;
            ((GoTextNode)this.FromNode).Shape.BrushColor = oldColor;
            ((GoTextNode)this.ToNode).Shape.BrushColor = oldColor;
        return true;

However, the problem is that when I select a link, delete it by pressing the “Delete” button on keyboard and then move the mouse, this triggers the OnEnterLeave method which changes the colors of the nodes. (Note that I dont move the mouse until after I press the delete button). How can I make sure that this method is not called or at least it does not execute color changing statements when it no longer exists ? I tried to use BeingRemoved property but it is false everytime. Any ideas ?

The current GoView.Tool has a property CurrentObject.

So, catch the link being deleted and do something like this if it was a link involved in highlighting…

    GoToolManager tool = view.Tool as GoToolManager;
    if (tool != null) tool.CurrentObject = null;

and you already know how to catch the link being deleted, we did that 2 week ago…

Thanks works perfect!

On a side note, when a link is deleted the hint is 903 (Which is correct). However, when deleting a collapsing record node item the hint is 901. Thus, I cannot catch when the collapsing record node item is being deleted. What is the correct way to achieve this ?

This is when an item is removed from a CRN? Check the subhint.

Yes, when the item is removed from the CRN by pressing delete. The subhint turned out to be 1052 which is same as CollapsingRecordNodeItem.RemovedObject. This seems to work for me.

Thanks so much for all your help, Jake.