views:

61

answers:

1

I am using Squeak (can't use Pharo), and I have a Morphic application and I wish to add my own custom Context-menu (I don't want to add to or use the Halo menu).

How do I build my menu and make it come up on a right-click (yellowButton, sigh)?

I currently have a CustomMenu and a handlerForYellowButtonDown: which calls the menu startup. The menu displays, but clicking on one of the selections has no effects. Any help or links greatly appreciated, thanks!

code snippets:

initialize
...
contextMenu := CustomMenu new title: 'Context Test Menu'.
contextMenu add: 'Clear - Erase Everything!' action: #menuStub.
contextMenu addLine.
contextMenu add: 'Do an Action' action: #menuStub:.

handlerForYellowButtonDown: event
Transcript show: 'yellowHandler';
show: Character cr.
contextMenu startUp

menuStub
Transcript show: 'menuStub';
show: Character cr

menuStub: something
Transcript show: 'menuStub: something';
show: Character cr

+1  A: 

The #invokeOn: method can be used to specify a target:

menu := CustomMenu new.
menu add: 'make sound' action: #beep.
menu invokeOn: Beeper.
Robert Krahn