Selection and subgraph

Hello,

I would like to have the following behaviour pertaining to selection and subgraph: When the user selects an object in a subgraph, if the current selection contains only objects that are in this subgraph, this object is added. Else, the subgraph itself is selected (on the parent subgraph of the subgraph, or its parent…).

What matters is that all selected object are at the same level in the graph/subgraph/subsubgraph… hierarchy.

I tried to look in the doc, but could not find where I could get this behaviour.

Best regards,

I haven’t tried this, but I would override GoSelection.Add and GoSelection.AddRange. You’ll need to override GoView.CreateSelection to return an instance of your new selection class.
I don’t know what problems might arise, though, when trying to add an object to the selection causes the selection to be cleared and a different object to be added to the selection.
An alternative to customizing GoSelection would be to limit all the calls to GoSelection.Add and .AddRange. However, there are a lot of ways that objects can get selected, so that would require customizing a bunch of tools.

Thank you, it seems to work.

I slightly changed my mind, I just prevent selection from unwanted levels, I do not try to be too much clever for the user and automatically select other objets instead.

Regards,