Enabling Undo/Redo with Application Framework Editor
First the GUI needs to be modified to allow the user to execute the Undo and Redo commands. This is done through the Application Framework Editor. Undo and Redo will be added to the Edit menu of the menu bar, and to the document-specific toolbar. As the Undo and Redo actions are predefined actions, it is not necessary to create new actions.
1. Launch the Application Framework Editor.
2. Open the BitmapEditor.odv file.
3. Click the Document Types icon located to the left:
4. Click ToolBars:
5. Select Paste in the Edit menu located in the tree displaying the menu bar and toolbar.
6. Insert a new action:
A new action has been added.
7. Select Undo in the Commands section:
8. Insert a new action.
9. Change the category to Editor.
10. Select Redo in the Commands section.
11. Remove the default editor actions not implemented in the editor: cut, copy, and paste.
From the Edit menu, select Cut and remove the command from the menu. Repeat this for the other non-relevant actions.
12. Find the document-specific toolbar in the tree (the last toolbar in the menu).
13. Select the last item of the toolbar.
14. Repeat steps 6 to 11 for the document-specific toolbar and then continue with step 15.
15. Save the file.
It is now possible for the user to trigger the Undo and Redo actions. These actions are automatically caught by the document.
You can compile and execute your application.
1. Launch the application.
2. Create a new bitmap.
3. Click and drag the mouse into the created view. You should see your modifications.
4. Open the Edit menu of the menu bar. The Undo action should be available.
5. Click on the Undo action. The last point drawn should disappear.
Published date: 05/24/2022
Last modified date: 02/24/2022