Hello Aliaa
To enable undo, you need to record all the associated actions - you can add them to a List.
For example - User Clicks a Red Button. The Red Button value is incremented and the Output Box is Incremented:
Record:
Red_ButtonID, increment
User then Clicks a Blue Button:
Record:
Red_ButtonID, increment
Blue_ButtonID, increment
User then Clicks a Green Button:
Record:
Red_ButtonID, increment
Blue_ButtonID, increment
Green_ButtonID, increment
When the User clicks Undo:
Green Button Value and Output Value are reduced by the amount recorded. Record is removed.
When the User clicks Undo again:
Blue Button Value and Output Value are reduced by the amount recorded. Record is removed.
When the User clicks Undo again:
Red Button Value and Output Value are reduced by the amount recorded. Record is removed
When the User clicks Undo again:
Nothing happens because the Undo Record is empty.