Advanced Features > Nested Managers and Nested Graphers > Selection in a Nested Manager > Selection Events

When a graphic object is selected or deselected, the manager will fire a selection event. This is described in Listener for the Selections in a Manager.

When a selection listener is registered in the manager using the method:

void addManagerSelectionListener(ManagerSelectionListener listener) 

it will only receive selection events for selections and deselections that are occurring in the manager where the listener was registered. To listen to selections that are taking place throughout a hierarchy of nested managers, the IlvManager class provides the following methods:

void addManagerTreeSelectionListener(ManagerSelectionListener listener) 
void removeManagerTreeSelectionListener(ManagerSelectionListener listener) 

When you register a selection listener using these methods, whenever an object is selected or deselected from a manager that is a submanager of the hierarchy of this manager, the listener will receive the event. Such a listener placed at the top-level manager of a hierarchy will then receive all the selection events of the hierarchy. To distinguish which submanager has sent the event, you can then use the method getManager on the event; the event is an instance of the class ManagerSelectionChangedEvent and contains the method:

IlvManager getManager()