How can I add an item in the World-menu of Pharo 4.0?
Asked Answered
D

1

6

How can I add a new item - Workspace openLabel: 'Workspace' - to the World-menu of Pharo 4.0 ? (What can I say... I prefer Workspace over the new what's-it-called. :-)

I've looked at several menu-related items in the Browser, but couldn't really make head or tails of it. I also tried to find where the menu is stored (it must be somewhere, right?), but couldn't find it.

Also, how would I go about to add it to one of the existing sub-menues of World-menu, and how could I create a new sub-menu (in the World-menu) and add it there?

Dort answered 23/6, 2015 at 17:1 Comment(1)
I like the new Playground a lot, but I also think for quick scripting the Workspace is the more straightforward tool. The names already suggest very well the different use cases. I think both should be included in the World Menu by default.Encomiast
E
5

Add the following class method to any class you like. Best to make one especially for this purpose and load it to your new images:

WorkspaceWorldMenuItem 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 put it directly after the selector (and comment) and before any other element in the method.

To have a look at example usage open Finder, choose the Pragmas mode and search for worldMenu (without the angle brackets).

Encomiast answered 23/6, 2015 at 19:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.