(newbee) Action on click?

Peace Jerome peace_the_dreamer at yahoo.com
Wed Nov 16 03:16:05 UTC 2005


Re: (newbee) Action on click?
Hi Marcus,

If what you want to do is supply your own menu then
the thing to do is

1) Subclass the morph class you want to have this
menu.
2 In catagory menu write a routine called:

addCustomMenuItems: aCustomMenu hand: aHandMorph

(look at some implementers of this and you will notice
they start out 

	super addCustomMenuItems: aCustomMenu hand:
aHandMorph. “skip this if all you want is the smaller
menu”
	
	self addMyCustomMenuItems: aCustomMenu hand:
aHandMorph



which puts all the usual menu items into the menu and
then adds your menu items.

then (actually beforehand) define:

addMyCustomMenuItems: aCustomMenu hand: aHandMorph
 aCustomMenu addLIne
 aCustomMenu add: 'update my Morph' translated action:
#UpdateMyMorph .

and of course define the action

UpdateMyMorph to do what you want.

If you know how to follow the implementors you should
just look at the examples. I strongly suggest writing
separate methods for each menu grouping. Its cleaner
and more flexible for reuse.

The is also a provision for each morph to have a
custom menu (I think control-red click ) which invokes
this method as well.

Happy hunting.

- (wiz) Jerome Peace
		


	

>Marcus Pedersén  wrote
>Tue Nov 15 22:44:07 CET 2005 
>
>Hi!
>I have made a morph and when I leftclick (red?)
>on it I want to make my own CustomMeny to appear.
>Do I have to subclass Morph and override message:
>mouseDown: evt?
>
>Or can I do it another way with the existing
>Morph class?
>
>Or am I on the wrong "path"?
>
>The reason that I do not want to subclass Morph
>is that it is a realy simple Morph and it feels
>unnessesary to make a new class just because I
>want to override one message.
>
>Many thanks in advance!
>Marcus



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com



More information about the Squeak-dev mailing list