ITT Rule IDL Version 7.0 Uživatelský manuál Strana 178

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 430
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 177
178 Chapter 7: Creating an Operation
Creating a New Generalized Operation iTool Developers Guide
Creating an UndoOperation Method
The operation class UndoOperation method is called when the user undoes the
operation by selecting “Undo” from a menu or toolbar.
Example UndoOperation Method
The following example code shows a very simple UndoOperation method for the
ExampleOp operation:
FUNCTION ExampleOp::UndoOperation, oCommandSet
; Retrieve the IDLitCommand objects stored in the
; command set object.
oCmds = oCommandSet->Get(/ALL, COUNT = nObjs)
; Get a reference to the iTool object.
oTool = self->GetTool()
; Loop through the IDLitCommand objects and restore the
; original values.
FOR i = 0, nObjs-1 DO BEGIN
oCmds[i]->GetProperty, TARGET_IDENTIFIER = idTarget
oTarget = oTool->GetByIdentifier(idTarget)
; Get the old value
IF (oCmds[i]->GetItem('OLD_STYLE', styleIndex) EQ 1) THEN $
oTarget->SetProperty, STYLE = styleIndex
ENDFOR
RETURN, 1
END
Discussion
The UndoOperation method does the following things:
1. Retrieves an array of IDLitCommand objects from the supplied
IDLitCommandSet object
2. Gets a reference to the iTool object.
3. For each command object, retrieve the identifier string for the target object.
Use the identifier string to retrieve a reference to the target object itself.
4. Retrieve the OLD_STYLE item from the command object and use its value to
set the STYLE property on the target object.
Zobrazit stránku 177
1 2 ... 173 174 175 176 177 178 179 180 181 182 183 ... 429 430

Komentáře k této Příručce

Žádné komentáře