[bug][fix] #setInvokingView: fails if a subMenu is used

Oca Emilio eoca at afip.gov.ar
Fri Mar 28 12:30:59 UTC 2003


Hi Squeakers,

As an example, if you try to use a submenu in a PlugableListMoph menu the
original version of MenuMorph>>setInvokingView: fails because it assumes
every item always has arguments.
This change set fixes this problem, but...
I used MenuMorph>>add:subMenu: which has several use examples.
MenuMorph>>add:subMenu:target:selector:argumentList: seems to use
'arguments' an in this case I think my fix doesn't works as it should. There
are no examples of how this method is used, may be it is of no use at all.
May be somebody could add a test case to help harvesters with this fix.

But (again) look at this method comment:
	"Re-work every menu item of the form
		<target> perform: <selector>
	to the form
		<target> perform: <selector> orSendTo: <invokingView>.
	This supports MVC's vectoring of non-model messages to the
editPane."

Is it correct to re-work this or is preferable to get it right when it is
built?

But more on this, look at the comment of the most common implementation of
this method:
perform: selector orSendTo: otherTarget
	"This should be the default in Object"

	(self respondsTo: selector)
		ifTrue: [^ self perform: selector]
		ifFalse: [^ otherTarget perform: selector]

Because Object has:
perform: selector orSendTo: otherTarget
	"If I wish to intercept and handle selector myself, 
	do it; else send it to otherTarget"
	^ otherTarget perform: selector

And Model has:
perform: selector orSendTo: otherTarget
	"Selector was just chosen from a menu by a user.  If can respond,
then perform it on myself.  If not, send it to otherTarget, presumably the
editPane from which the menu was invoked." 

	"default is that the editor does all"
	^ otherTarget perform: selector.

A consequence of this is that, if you use PlugableSomethingMorph, you have
to rewrite #perform:orSendTo: to get messages sent to self instead of
plugableSomethingMorph.

Do I miss something? Is this the intended behavior?

	Emilio



'From Squeak3.4 of 1 March 2003 [latest update: #5170] on 27 March 2003 at
11:33:56 pm'!

!MenuMorph methodsFor: 'menu' stamp: 'efo 3/27/2003 23:32'!
setInvokingView: invokingView
	"Re-work every menu item of the form
		<target> perform: <selector>
	to the form
		<target> perform: <selector> orSendTo: <invokingView>.
	This supports MVC's vectoring of non-model messages to the
editPane."
	self items do:
		[:item |
		item hasSubMenu 
			ifTrue: [ item subMenu setInvokingView:
invokingView]
			ifFalse: [ item arguments isEmpty ifTrue:  "only the
simple messages"
						[item arguments: (Array
with: item selector with: invokingView).
						item selector:
#perform:orSendTo:]]]! !

-------------- next part --------------
A non-text attachment was scrubbed...
Name: MenuMorph-setInvokingView.st
Type: application/octet-stream
Size: 682 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030328/3a826a6e/MenuMorph-setInvokingView.obj


More information about the Squeak-dev mailing list