[Cuis-dev] registerAll/unregisterAll menus

Hernán Wilkinson hernan.wilkinson at 10pines.com
Tue Apr 29 04:56:04 PDT 2025


Hi,
 packages that add menus can have a lot of repeated code to add them and
remove them.
 The attached .cs adds two messages to SystemWindow to avoid that
duplicated code: registerAll: and unregisterAll:
 With this messages, code that look like this:

initialize
BrowserWindow
   at: #systemCatListMenuSpec
   registerMenuAndShortcutsSpecProvider: (MessageSend receiver: self
selector: #systemCatListMenuSpec).
BrowserWindow
   at: #classListMenuSpec
   registerMenuAndShortcutsSpecProvider: (MessageSend receiver: self
selector: #classListMenuSpec).
... and so on

unload
BrowserWindow
   at: #systemCatListMenuSpec
   unregisterMenuAndShortcutsSpecProvider: (MessageSend receiver: self
selector: #systemCatListMenuSpec).
BrowserWindow
   at: #classListMenuSpec
   unregisterMenuAndShortcutsSpecProvider: (MessageSend receiver: self
selector: #classListMenuSpec).
... and so on

Now it looks like this:
initialize
   BrowserWindow registerAll: self browserWindowMenuSpecs.
unload
   BrowserWindow unregisterAll: self browserWindowMenuSpecs.
browserWindowMenuSpecs
   ^{ { #systemCatListMenuSpec. self systemCatListMenuSpecSend }.
       { #classListMenuSpec. self classListMenuSpecSend }}

Cheers!
Hernan.

-- 

*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250429/8acaf609/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 7108-RegisterUnregisterAllMenuSpecs-HernanWilkinson-2025Apr28-20h59m-HAW.001.cs.st
Type: application/octet-stream
Size: 491 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250429/8acaf609/attachment.obj>


More information about the Cuis-dev mailing list