Morph menus
Last updated at 4:46 pm UTC on 16 January 2006
Every Morph has a menu which can be accessed though its halo.
It reflects some of the messages you can send to the Morph. You may add additional entries. There's a hook to do this. Every Morph calls the message:
addCustomMenuItems: aCustomMenu hand: aHandMorph
and the implementation. All you have to do is to override this message in your Morph subclass.
Example
addCustomMenuItems: aCustomMenu hand: aHandMorph
super addCustomMenuItems: aCustomMenu hand: aHandMorph.
aCustomMenu add: 'my own menu entry' action: #myAction.
You have to provide a method #myAction as well.
Example
Change the method
addCustomMenuItems: aCustomMenu hand: aHandMorph
super addCustomMenuItems: aCustomMenu hand: aHandMorph.
aCustomMenu add: 'change font' action: #changeFont.
aCustomMenu add: 'change emphasis' action: #changeEmphasis.
aCustomMenu add: 'add jump-to-project action' action: #addJumpToProjectAction "<-- this line is added"
and create a new method
addJumpToProjectAction
| m choice |
m _ *2320* new.
Project allNames do: [:name | m add: name action: name].
choice _ m startUp.
self addMouseUpActionWith: '(Project named: ''' , choice , ''') enter'
Hannes Hirzel, February 2001
Q. [Feb-2003] Which method do I have to override if I want to replace the menu of a morph completely with my own menu?
A. Override addStandardHaloMenuItemsTo: aMenu hand: aHandMorph. (Morph menus)