user manual
214 Chapter 8: Creating a Manipulator
Creating a New Manipulator iTool Developer’s Guide
up initial values required for manipulator actions. If your manipulator calls a custom
operation or the SET_PROPERTY operation, and you want to enable undo/redo
support, call the RecordUndoValues method in the OnMouseDown method to record
the initial values. See “Manipulators and the Undo/Redo System” on page 202 for
more information.
Example OnMouseDown Method
The following example code shows a simple OnMouseDown method for the
ExampleManip manipulator. All this method does is set class structure fields.
PRO ExampleManip::OnMouseDown, oWin, x, y, iButton, $
KeyMods, nClicks
; Call our superclass.
self->IDLitManipulator::OnMouseDown, $
oWin, x, y, iButton, KeyMods, nClicks
; Return if no visualization was selected.
IF (self.nSelectionList EQ 0) THEN $
RETURN
; Access the first selected item and make sure it is an image.
oImage = (*self.pSelectionList)[0]
IF (OBJ_ISA(oImage,'IDLitVisImage')) THEN BEGIN
; Set the oImage field of the class structure to be
; the retrieved IDLitVisImage object.
self.oImage = oImage
; Record the current values for the target objects.
iStatus = self->RecordUndoValues()
ENDIF
END
Discussion — When the ExampleManip manipulator is activated and the user clicks
in the iTool window, the OnMouseDown method calls the superclass (in order to
update the public instance fields) and makes sure a visualization was selected. If the
selected visualization is an image, store the image in the class structure field created
when the ExampleManip class structure is defined. Call the RecordUndoValues
method to support undo/redo functionality.
Implementing an OnMouseMotion Method
The manipulator class OnMouseMotion method is called when a mouse motion event
occurs over the target window. This method provides access to the window object,
the
x
,
y
window coordinates of the cursor, and which modifier key (if any) is
depressed during mouse motion. The
ButtonPress instance data field can be used