Saving the widget
To save the state of a widget when a stack containing the widget is saved we implement the OnSave handler.
Add the OnSave handler to the widget code
- add an element for each property
- key: property name
- value: property value
The rProperties array is an out parameter meaning  the value of the array is copied back to the caller when the handler completes.
public handler OnSave(out rProperties as Array) put mValues into rProperties["values"] put mLabels into rProperties["labels"] put mShowLabels into rProperties["showLabels"] end handler
Loading the widget
Next we write the OnLoad handler, which loads the widget’s properties when a stack containing a widget is opened.
Add the OnLoad handler to the widget code.
The array of saved properties is passed in as a parameter, and can be used to set the values of the private instance variables to the stored property values.
public handler OnLoad(in pProperties as Array) put pProperties["values"] into mValues put pProperties["labels"] into mLabels put pProperties["showLabels"] into mShowLabels end handler