简体   繁体   English

如何在Pharo 4.0的World菜单中添加项目?

[英]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 ? 如何在Pharo 4.0的World-menu中添加一个新项目 - Workspace openLabel:'Workspace'? (What can I say... I prefer Workspace over the new what's-it-called. :-) (我能说什么......我更喜欢Workspace而不是新的东西。:-)

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? 另外,我将如何将其添加到World-menu的现有子菜单之一,如何创建新的子菜单(在World-menu中)并将其添加到那里?

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 WorkspaceWorldMenuItem类>> menuCommandOn:aBuilder

menuCommandOn: aBuilder
<worldMenu>

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

The interesting part is the <worldMenu> pragma. 有趣的部分是<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). 要查看示例用法打开Finder ,请选择Pragma模式并搜索worldMenu (不带尖括号)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM