[enh] factored HandMorph openMenu
dway at mat.net
Wed Mar 8 19:35:53 UTC 2000
Yes, this is very handy! I tried it out and it seems to work well.
I was also getting tired of having my open-menu customizations being
overwritten all the time by updates. So, consider this a plug for
inclusion in the base image.
(I suppose it might be nice to have all menus (not just these four)
handled in a conflict-avoiding way like this... still, this is a good
- Doug Way
EAI/Transom Technologies, Ann Arbor, MI
dway at mat.net, @eai.com
On Tue, 7 Mar 2000, Stephan B. Wessels wrote:
> Have you ever had a situation where multiple change sets you've written all make
> extensions or modifications to the #openMenu method in HandMorph? It's pretty
> easy to get a collision where you edit the method but forget to file out all of
> the change sets that have conflicting interests. Later when you load them back
> in to a "virgin" image, the last change set loaded "wins" with it's version of
> the open menu.
> Or how about when someone adds some really cool new tool you just have to
> install, but then notice that your own menu items were replaced?
> This change set addresses the issue of individuals wanting to add their own
> extensions to the open menu method in HandMorph without colliding and
> overwriting. It uses the same technique used in the latest Preferences code in
> V2.8a. I've extended the open menu, appearance menu and changes menu to use
> this technique. I've also added a hook to the file list menu that gets modified
> pretty often in File List too.
> For the HandMorph open menu here's the procedure you use to add in your own open
> menu items:
> 1. Create a new method to add your menu item in the HandMorph category 'user
> defined open menu items'. For example the menu item should look like this...
> (note the argument <menu> is passed along)
> openDualFileListMenuItem: menu
> | morphItemAbove item |
> morphItemAbove _ menu lastItemWithSelector: #openFileDirectly.
> morphItemAbove isNil ifTrue: [^nil].
> item _ MenuItemMorph new
> contents: 'dual file list';
> target: menu defaultTarget;
> selector: #openDualFileList;
> arguments: EmptyArray.
> item setBalloonText: 'Open up a dual file list.'.
> menu addMorph: item behind: morphItemAbove.
> The above example adds a menu item named 'dual file list' with the selector
> #openDualFileList that gets inserted directly underneath the existing menu item
> that uses the selector #openFileDirectly.
> To add a menu line do something like this inside the method:
> menu addMorph: MenuLineMorph new behind: aPreviousMenuItemMorph.
> You can also just add new menu items easily to the end of the open menu by
> writing a method using the standard add:action: type selectors.
> The beauty of this approach to extending the open menu is that you keep the
> parts that are pertinent to the change set you are writing with the change set
> and you leave the open menu code alone. (After this extension gets installed of
> I encourage that we adopt this technique for menus that have level of sharing.
> About the only likely collisions now would be common method names.
> Hope someone likes this...
> - Steve
More information about the Squeak-dev