Getting the selected nodes in an ICE Tree


You can get the selected ICE nodes through the selection view attribute.

First, you have to get the ICE Tree view. You could try to get the view by name:

var oLayout = Application.Desktop.ActiveLayout;
var oICETreeView = oLayout.Views( "ICE Tree" );

but if the ICE Tree view is part of a layout (like the ICE layout) that won’t work, because the view has a different name (for example, in the ICE layout, the view name is “lower_panel”). To be sure you get the ICE Tree view, whether it is floating or embedded, filter by the Views by type.

// Get the ICE Tree views
var oLayout = Application.Desktop.ActiveLayout;
var oICETreeViews = oLayout.Views.Filter( "ICE Tree" );

// Now get the selected nodes 
// and log the names of the selected nodes
var x = oICETreeViews(0);
var a = x.GetAttributeValue( "selection" ).split(",");
LogMessage( a.length );

for ( var i in a )
{
	var oNode = Dictionary.GetObject( a[i] );
//	LogMessage( classname(oNode) );
	LogMessage( oNode.Name );
}