Using Manipulator Public Instance Data
The IDLitManipulator class automatically manages selection state between mouse-down and mouse-up interactions. Three public instance fields are exposed, providing information about the mouse button state (ButtonPress), the number of selected items (nSelectionList), and an array of the currently selected visualizations (pSelectionList).
Note
These fields are set by the OnMouseDown method of IDLitManipulator, which would be called by the OnMouseDown method of the subclass. These fields are therefore available after a mouse down event in the iTool window.
Using the ButtonPress Field
The ButtonPress field holds the state of mouse buttons when a manipulator has been activated. For example, suppose your manipulator requires the user to hold down a mouse button while moving the mouse cursor to affect some aspect of the visualization. You could use a pointer, set in the mouse down event and not reset until the mouse up event, to indicate the user is holding down the mouse button. However, a more efficient way is to use the built-in ButtonPress field to access the same information. The ButtonPress field is a bitmask with the following possible values:
To determine if the user is holding down a mouse button, query the ButtonPress field in the OnMouseMotion method. Prior to manipulating a visualization, a statement such as the following would assure a mouse button was pressed:
You could modify this statement to determine which mouse button is pressed or access the field in one of the other mouse transaction methods. See Creating Mouse Event Methods for more information about the OnMouseDown, OnMouseMotion and OnMouseUp methods.
Using the nSelectionList Field
The nSelectionList field contains the number of currently selected items in the window associated with the current manipulator. This corresponds to the number of visualizations contained within the pSelectionList pointer, described in the following section. If no visualizations have been selected, the nSelectionList value equals 0 and the pSelectionList will contain an undefined IDL variable. The nSelectionList can be used to ensure the user has made a selection. For example, in an OnMouseDown method, you may use a statement similar to the following to ensure a selection has been made:
The nSelectionList field value can also be used to loop through the collection of selected visualizations as shown in the following section.
Using the pSelectionList Pointer Field
The pSelectionList field is a pointer to an array of visualizations currently selected in the window. Use the nSelectionList value to cycle through this array. If a manipulator only acts upon visualizations of a certain type you can verify the type of each selected item in pSelectionList before attempting to modify the visualization. The nSelectionList and pSelectionList public instance data fields are available from any manipulator object's predefined or custom methods.
; Loop through all selected visualizations. FOR i=0, self.nSelectionList-1 DO BEGIN oVis = (*self.pSelectionList)[i] ; Verify type of visualization or manipulate it. ; ... ENDFORNote
ThepSelectionListfield is a pointer. You must use IDL pointer syntax to access items in the field.
See Example: Color Table Manipulator for a complete example that uses these public instance data fields.