Programmatic Node Selection

Hi Guys,

I have a MultiPortSubGraph (like the class item in Demo1) containing CollapsingRecordNodeItemList which contains collection of CollapsingRecordNodeItem.
pic1: user clicks on the "Prefix" item - it becomes selected
pic2: I want the subgraph to be selected as well
My requirement is that whenever the user clicks on one of the CollapsingRecordNodeItem, the SubGraph itself will be selected (and highlighted) but remain the feeling as if the CollapsingRecordNodeItem was selected. In other words - i want both entities to look like selected while only the SubGraph is really selected.
hope my question was clear...
Adi Barda

To be clear, you don’t want highlit items to be deleted or copied or dragged around independently from the whole CollapsingRecordNode, right?

So the first step is to set this.Selectable = false in the CollapsingRecordNodeItem and CollapsingRecordNodeItemList constructors. That way when the user clicks on any item, only the whole node is selected.

The second step is to change the appearance of the items when the user clicks on it. Add this override to CollapsingRecordNodeItem:

public override bool OnSingleClick(GoInputEventArgs evt, GoView view) { if (myAppearanceSaved) RemoveSelectionHandles(view.Selection); else AddSelectionHandles(view.Selection, this); return true; }
You didn’t say whether when the whole node loses selection whether the items should not appear highlit. If you do want that, that’s easy enough too. Just add an OnLostSelection override in CollapsingRecordNode:

[code] public override void OnLostSelection(GoSelection sel) {
RemoveAppearances(this.List, sel);

private void RemoveAppearances(CollapsingRecordNodeItemList list, GoSelection sel) {
  foreach (GoObject o in list) {
    CollapsingRecordNodeItem item = o as CollapsingRecordNodeItem;
    if (item != null) {
    } else {
      CollapsingRecordNodeItemList l = o as CollapsingRecordNodeItemList;
      if (l != null) RemoveAppearances(l, sel);

and the additional method in CollapsingRecordNodeItem:

public void RemoveAppearance(GoSelection sel) { if (myAppearanceSaved) RemoveSelectionHandles(sel); }

Thanks Walter,

I've made few changes to your suggestion but in general it works very good.
As usual - Best support!!!