How to add an item to the Pharo 4.0 global menu?

How to add a new element - Workspace openLabel: "Workspace" - in the Pharo 4.0 World-menu? (What can I say ... I prefer the workspace over the new one that they call it. :-)

I looked at a few menu-related items in the browser, but couldn't really make a head or tail out of it. I also tried to find where the menu is stored (it should be somewhere, right?), But could not find it.

In addition, how can I add it to one of the existing submenus of the World menu, and how can I create a new submenu (in the World menu) and add it there?

+6
source share
1 answer

Add the following class method to any class. It is best to do this specifically for this purpose and upload it to new images:

Workspace WorldMenuItem class -> menuCommandOn: aBuilder

menuCommandOn: aBuilder <worldMenu> (aBuilder item: #'Workspace') order: 0.1; label: 'Workspace'; action: [ Workspace open ] 

The interesting part is the <worldMenu> pragma. You usually place it immediately after the selector (and comment) and before any other method element.

To see an example of using Open Finder, select Pragmas mode and search for worldMenu (without angle brackets).

+5
source

Source: https://habr.com/ru/post/989633/


All Articles