GoLink

I’m using the event objectEnterLeave, and my objective is when the mouse enter in a GoLink, that link stays hidden. When the mouse leaves the link stays visible again.
It’s possible to do this?

That’s an unusual behavior that you seek.

I assume you tried the obvious implementation:
private void myView_ObjectEnterLeave(object sender, GoObjectEnterLeaveEventArgs e) {
if (e.From != null) {
GoLink link = e.From as GoLink;
if (link != null) {
link.SkipsUndoManager = true;
link.Visible = true;
link.SkipsUndoManager = false;
}
}
if (e.To != null) {
GoLink link = e.To as GoLink;
if (link != null) {
link.SkipsUndoManager = true;
link.Visible = false;
link.SkipsUndoManager = false;
}
}
}
If you are using GoLabeledLink instead of GoLink, you'll probably want to do this:
GoLabeledLink link = e.From.ParentNode as GoLabeledLink;
instead of:
GoLink link = e.From as GoLink;
(and the same for the e.To GoObject, of course). You wouldn't have to worry about these cases if you were overriding the GoObject.OnEnterLeave method.
The temporary binding of SkipsUndoManager is because I assume you don't want to record these changes for undo/redo, which is usually the case for this event.
The problem is that by making something not Visible, the mouse can no longer be "in" it. So as soon as the mouse moves, no matter where it moves to, the mouse point cannot be inside that link again.
One solution is to leave it be Visible and to change it to use a clear Pen. The link is then still responsive to mouse events, but it is not drawn.
private Pen myOldLinkPen = null;
private void myView_ObjectEnterLeave(object sender, GoObjectEnterLeaveEventArgs e) {
if (e.From != null) {
GoLink link = e.From as GoLink;
if (link != null) {
link.SkipsUndoManager = true;
link.Pen = myOldLinkPen;
link.SkipsUndoManager = false;
}
}
if (e.To != null) {
GoLink link = e.To as GoLink;
if (link != null) {
link.SkipsUndoManager = true;
myOldLinkPen = link.Pen;
if (myOldLinkPen != null) {
link.Pen = new Pen(Color.Empty, myOldLinkPen.Width);
}
link.SkipsUndoManager = false;
}
}
}