|
Object » PopUpMenu » SelectionMenu » CustomMenu
Class CustomMenu associates a menu item not only with a selector, but also with a message receiver, the so-called 'target' and a message argument. CustomMenus are built for single use.
The MouseMenuController requests the menu from the view. It also delegates the execution of the selected activity to the menu. The CustomMenu allows the view to assign the responsibility for some selectable activities to itself. The CustomMenu is therefore a good choice whenever the view has to carry out some activities without support from its model.
add: aString
target: target
selector: aSymbol
argument: arg
add an item that is named aString. The item will be processed
by target. If the item is selected, the following expression
is evaluated:
target perform: aSymbol with: arg
add: aString
target: target
selector: aSymbol
argumentList: aCollection
add an item that is named aString. The item will be processed
by target. If the item is selected, the following expression
is evaluated:
target perform: aSymbol withArguments: aCollection
addLine
Append a line to the menu after the last entry. Suppress duplicate
lines.
| menu | menu := CustomMenu new. menu add: 'red rectangle' target: Display selector: #fill:fillColor: argumentList: (Array with: (10@10 extent: 100@100) with: Color red); add: 'green rectangle' target: Display selector: #fill:fillColor: argumentList: (Array with: (10@10 extent: 100@100) with: Color green); addLine; add: 'browser' target: Browser selector: #fullOnClass: argument: nil; add: 'browser on Pen' target: Browser selector: #fullOnClass: argument: Pen; add: 'browser on Pen class' target: Browser selector: #fullOnClass: argument: Pen class; add: 'browser on Collection' target: Browser selector: #fullOnClass: argument: Collection; addLine; add: 'inspect' target: Inspector selector: #openOn:withEvalPane: argumentList: (Array with: menu with: false). menu invokeOn: nil
|