Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
MenuMorph
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...
Screen Shot 2014-03-20 at 12.41 PM.png
	| menu |
	menu := MenuMorph new defaultTarget: self .
	menu add: 'show' action: #makeVisible.
	menu add: 'export this sprite' action: #exportObject.
	menu addLine.
	menu add: 'duplicate' action: #duplicateNoAttach.
	menu add: 'delete' action: #undoableDeleteSprite.
	menu popUpInWorld


or have icons, submenus, titles, help balloons and inter-item lines...
World menu
Screen Shot 2014-03-20 at 12.57 PM.png
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.

PopUp menu


aMenu popUpInWorld
Demo