Contents

Class CustomMenu


Inheritance:

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.

Important Instance Methods

Examples of Use:

 | 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

Contents