ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Controls, pages and windows / Action functions
  • Overview
  • How to?
  • Example
  • WLanguage functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Managing actions with Undo/Redo
Overview
WINDEV allows you to easily manage the Undo/Redo feature in your applications with the ActionXXX functions. To do so, the user can press Ctrl + Z and Ctrl + Y to easily undo or redo an action.
How to?
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 as parameter the name of the procedure that corresponds to the action. 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 as parameter the name of the procedure to run. This procedure can be a local, global or internal procedure.
  3. Use the following functions if necessary:
Remarks:
  • 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 context 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 PROCEDURE Color
EDT_LastName.BackgroundColor = PastelGreen
EDT_FirstName.BackgroundColor = PastelRed
 
ActionDeclareUndo(GoBack)
INTERNAL PROCEDURE GoBack
EDT_LastName.BackgroundColor = DefaultColor
EDT_FirstName.BackgroundColor = DefaultColor
END
END
To allow the user to undo several actions, simply call ActionDo several times with different procedures. For example:
ActionDo(WIN_ACTION, Color)
ActionDo(WIN_ACTION, StoreValue)
 
INTERNAL PROCEDURE Color
EDT_LastName.BackgroundColor = PastelGreen
EDT_FirstName.BackgroundColor = PastelRed
 
ActionDeclareUndo(GoBack)
INTERNAL PROCEDURE GoBack
EDT_LastName.BackgroundColor = DefaultColor
EDT_FirstName.BackgroundColor = DefaultColor
END
END
 
INTERNAL PROCEDURE StoreValue()
EDT_LastName.Note = EDT_LastName
EDT_FirstName.Note = EDT_FirstName
 
ActionDeclareUndo(GoBack)
INTERNAL PROCEDURE GoBack
EDT_LastName = EDT_LastName.Note
EDT_FirstName = EDT_FirstName.Note
END
END
In this example, the first Ctrl + Z will undo the storage of values and the second will undo the coloring of controls.
WLanguage functions
The following WLanguage functions are used to manage the actions:
ActionDeclareUndoDeclares how to cancel an action that was added by ActionDo. This function MUST be called when running the procedure supplied to ActionDo.
ActionDoCreates and runs a custom action (defined through programming) with support of "Undo/Redo".
ActionRedoRuns the last action canceled.
ActionUndoCancels the last action performed by the end user.
See also
Minimum version required
  • Version 22
Comments
Click [Add] to post a comment

Last update: 01/26/2023

Send a report | Local help