Change selecting of link class

Walter, may i ask your advice again? I have a link class which is
painted as polygon to represent different link widths. My problem is,
that the link can only be selected when user clicks directly on or at
least near the stroke. Is there a way to use a click in the polygon to
select the link?

If you override GoObject.Paint, you might also consider overriding:
ExpandPaintBounds, so that the GoView knows what area needs to be repainted, if it’s more than the Bounds
ContainsPoint, if you want GoObject.Pick to be smarter about what points the user can click on to select an object
ContainedByRectangle, similarly for the PickObjectsInRectangle methods on GoDocument, GoView, and GoLayer
GetNearestIntersectionPoint, mostly commonly used by links and ports to decide where to terminate a link, but used elsewhere too; the default is the result of GoObject.GetNearestIntersectionPoint(this.Bounds, …) which assumes the object is just a rectangle.

ExpandPaintBounds
ContainsPoint
ContainedByRectangle

done

GetNearestIntersectionPoint

not done so far

Thank you, walter. What do you think about adding this information to
your ‘User Guide’? Maybe this can start a section where the different
steps are described to solve some specifc implementation problems.

But unfortunatly i got stuck at another thing. The bounding rectangle
of my link is too small. It just includes all points of the stroke. But
it has to contain all points of the polygon. Otherwise the link does
not become selected when i click into the polygon but outside of the
bounding rectangle. If i set ‘this.Bounds’ to the bounds i calculate in
ExpandPaintBounds, my link jumps around when i insert points to the
link interactively. How do i have to initialize the bounds of the link?

Well, you could override Pick, too.
It looks like you’re needing to reimplement everything, which to me is an indication that there’s probably an easier way to do what you want.
Here’s an idea. Why not use a GoPolygon? Two possibilities:
You could have it implement IGoLink, which is a little work. But if you don’t really want to use a GoLink (which is a GoStroke), because you don’t want the user to think of it as being a segmented line, this would be best.
Or if you do want to use a GoLink, you could use a GoLabeledLink and have the GoPolygon be the MidLabel (or any other label or child). If it’s the MidLabel, you can override LayoutMidLabel to reshape the polygon the way you want it to be, to follow the points of the link stroke.

Well, you could override Pick, too.

My link is of type GoLabeledLink and i tried it. It was executed on
every MouseMove within GoView. Seems to be a bit oversized and i am not
sure if this becomes an performance issue for large net works.

Now i am overriding ComputeBounds in my link class and everything seems to work fine.

Here’s an idea. Why not use a GoPolygon? Two possibilities:
You could have it implement IGoLink, which is a
little work. But if
you don’t really want to use a GoLink
(which is a GoStroke), because
you don’t want the user to think of it
as being a segmented line, this
would be best.

Although the link has to be painted as polygon user may want to insert points into stroke.

Or if you do want to use a GoLink, you could use a GoLabeledLink
and
have the GoPolygon be the MidLabel (or any other label or
child).
If it’s the MidLabel, you can override LayoutMidLabel to
reshape the
polygon the way you want it to be, to follow the points
of the link
stroke.

Cool idea to use a GoPolygon as label. If there will be more problems with my current realization i will switch to this.