[Q] MenuMorph add:subMenu: trouble
Aaron Thieme
ghede at well.com
Sat Jul 22 22:50:16 UTC 2000
Hi,
Hoping some morphic guru can riddle something for me.
I am constructing a pop-up menu for my own morph subclass.
Menus with no popups are working fine. However, when I try to use
add:subMenu to append a subMenu under certain conditions, as so:
subMenu := MenuMorph new.
subMenu add: 'foo' action: #bar.
...
mainMenu addLine.
mainMenu add: 'sub...' subMenu: subMenu.
...
... I get an error when the menu is instantiated (not when it's being
created!). Digging showed the problem to be that the MenuItemMorph titled
'sub...' has no arguments; there's an iterating block context (over the
items in the main menu) in something like "instantiateInView" that assumes
that "item arguments" will return a collection. In my case, for whatever
reason, arguments is nil and I get an error.
There are no variations of add:subMenu: that assign an arguments list, or
default it to an empty collection, as far as I can tell.
I patched this by changing MenuItemMorph to passively initialize
arguments to an empty collection if it's nil, but haven't been able to
figure out why the normal old system menus/submenus -- which apparently
construct submenus exactly as I am doing -- don't encounter this problem.
Any elucidation as to what I might be doing wrong would be much appreciate
-- I'm assuming there's a reason/philopophy behind why the argments
accessor doesn't passive initialize in MenuItemMorph; and hence that my
"patch" is just obscuring a deeper oversite on my part... :) Else, I'll
submit it!
Thanks and best regards,
aaron
ghede at well.com
http://www.quietamerican.org
More information about the Squeak-dev
mailing list
|