PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • How to proceed?
  • Example
  • WLanguage functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Managing actions with Undo/Redo
Overview
WINDEV allows you to easily manage the Undo/Redo feature in your applications via the ActionsXXX functions. To do so, the user can press CTRL + Z and CTRL + Y to easily undo or redo an action.
How to proceed?
To manage the Undo/Redo feature in your WINDEV applications:
  1. Declare the actions to save in the stack of actions performed by ActionDo. This function expects the name of the procedure corresponding to the action in parameter. This procedure can be a local, global or internal procedure.
  2. In the code of the procedure corresponding to the action to perform, use ActionDeclareUndo to define the code that will be run to cancel the action. This function expects the name of the procedure to run in parameter. This procedure can be a local, global or internal procedure.
  3. Use the following functions if necessary:
Notes:
  • You cannot stack several times the SAME actions defined by ActionDo. Each action requested by ActionDo deletes the previous identical action. Therefore, only the last SAME action can be canceled.
  • In the popup menu of a control, the "Cancel" option proposed by default does not have the same effect as ActionUndo or Ctrl Z.

Example

The following example is used to modify the background color of two edit controls. This action can be undone by CTRL + Z:
ActionDo(WIN_ACTION, Color)

INTERNAL PROCÉDURE Color
EDT_LastName..BrushColor = PastelGreen
EDT_FirstName..BrushColor = PastelRed

ActionDeclareUndo(GoBack)
INTERNAL PROCÉDURE GoBack
EDT_LastName..BrushColor = DefaultColor
EDT_FirstName..BrushColor = DefaultColor
END
END
To allow the user to cancel several actions, all you have to do is use ActionDo several time with different procedures. For example:
ActionDo(WIN_ACTION, Color)
ActionDo(WIN_ACTION, StoreValue)

INTERNAL PROCÉDURE Color
EDT_LastName..BrushColor = PastelGreen
EDT_FirstName..BrushColor = PastelRed

ActionDeclareUndo(GoBack)
INTERNAL PROCÉDURE GoBack
EDT_LastName..BrushColor = DefaultColor
EDT_FirstName..BrushColor = DefaultColor
END
END

INTERNAL PROCÉDURE StoreValue()
EDT_LastName..Note = EDT_LastName
EDT_FirstName..Note = EDT_FirstName

ActionDeclareUndo(GoBack)
INTERNAL PROCÉDURE GoBack
EDT_LastName = EDT_LastName..Note
EDT_FirstName = EDT_FirstName..Note
END
END
In this example, the first CTRL + Z will cancel the storage of values and the second one will cancel the coloring of controls.
WLanguage functions
The following WLanguage functions are used to manage the actions:
Versions 22 and later
ActionDeclareUndo
New in version 22
ActionDeclareUndo
ActionDeclareUndo
Declares how to cancel an action that was added by ActionDo. This function MUST be called when running the procedure supplied to ActionDo.
Versions 22 and later
ActionDo
New in version 22
ActionDo
ActionDo
Creates and runs a custom action (defined by programming) with support of "Undo/Redo".
Versions 22 and later
ActionRedo
New in version 22
ActionRedo
ActionRedo
Runs the last action canceled.
Versions 22 and later
ActionUndo
New in version 22
ActionUndo
ActionUndo
Cancels the last action performed by the end user.
See also
Minimum required version
  • Version 22
Comments
Click [Add] to post a comment