Last updated at 5:55 pm UTC on 30 March 2017
MenuMorph is the primary Morphic menu class. This page refers to the 4.5 state of MenuMorph.
Menus can be as simple as a plain list of text...
| menu |
menu := MenuMorph new defaultTarget: self .
menu add: 'show' action: #makeVisible.
menu add: 'export this sprite' action: #exportObject.
menu add: 'duplicate' action: #duplicateNoAttach.
menu add: 'delete' action: #undoableDeleteSprite.
or have icons, submenus, titles, help balloons and inter-item lines...
The menu has a list of MenuItemMorphs which are typically built with messages such as #add:action:, #add:selector:argument: - see the 'construction' protocol in MenuMorph. Each item needs a target to which the relevant selector is sent; an argument (or list of arguments) can be attached as well. The target can be provided as a default or explicitly for each item.