Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

smalltalk - How can I add an item in the World-menu of Pharo 4.0?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...