A problem with the link selection


The matter with the XML transformers has been resolved, and I'm very thankful for your help.
Now I have a question about selecting the objects. When I'm selecting my GoLabeledLink link, I'd like some other (child) GoObjects to be selected as well. I tried with overriding the SelectionObject property, but I couldn't return the collection of objects. Finally I made my own GoToolSelecting and implemented the wanted behaviour there. But my implementation is poor in the case of selecting a lot of different objects. I overrode the GoToolSelecting DoSelect method, so it iterates along the selected objects and searches for links. If it finds a link, it adds some nodes related to it to the view's GoSelection. Now, if I wanted to apply special selection behaviour to some other objects, I'd have to repeat this sequence and it becomes time - consuming. Can you tell me if I could somehow override the SelectionObject to select more than one object, or at least any idea to implement this quicker? Thanks.

Are you saying that when a GoLabeledLink is selected, you also want some or all of its labels to be “selected” too? The nodes that are connected by the link are not children of the link, so what you are saying is ambiguous. What effect are you trying to achieve?

Do you just want to have the children of the link be “highlit” somehow? Or do you really want to treat those child objects as separately selected objects?

For the former case, you can override GoLabeledLink.AddSelectionHandles and RemoveSelectionHandles. But you should just do this for real child objects of the link, not for independent objects such as connected nodes.

For the latter case, what you are doing by overriding GoToolSelecting.DoSelect should work fine if you just care about having this effect when the user clicks on a link. But note that you won’t get that effect when the link is selected in some other manner, such as by rubber-band selection, or programmatic selection.

Regarding GoObject.SelectionObject – it really is meant to provide a visual substitution of the selected object. For some of the predefined node classes, the SelectionObject is the node’s Icon or Shape. This way it appears that the primary/central thing of the node is what is selected, when really it is the whole node that shows up in the GoView.Selection collection. That’s why it’s only a single object. But as I just pointed out, you can have multiple selection handles if you want more complicated highlighting of the selection.