Squeak 中的上下文菜单

发布于 2024-07-26 07:23:18 字数 737 浏览 2 评论 0原文

我正在使用 Squeak(不能使用 Pharo),并且我有一个 Morphic 应用程序,并且我希望添加自己的自定义上下文菜单(我不想添加或使用 Halo 菜单)。

如何构建我的菜单并使其在右键单击时出现(黄色按钮,叹息)?

我目前有一个 CustomMenu 和一个 handlerForYellowButtonDown: ,它调用菜单启动。 菜单显示,但单击其中一个选项没有任何效果。 非常感谢任何帮助或链接,谢谢!

代码片段:

初始化
...
contextMenu := CustomMenu 新标题:“上下文测试菜单”。
contextMenu 添加:“清除 - 删除所有内容!” 操作:#menuStub。
上下文菜单添加行。
contextMenu 添加:“执行操作”操作:#menuStub:。

handlerForYellowButtonDown:事件
文字记录显示:'yellowHandler';
显示:角色 cr.
contextMenu 启动

菜单Stub
文字记录显示:'menuStub';
显示:角色 cr

menuStub:某事
文字记录显示:'menuStub:某事';
显示:角色cr

I am using Squeak (can't use Pharo), and I have a Morphic application and I wish to add my own custom Context-menu (I don't want to add to or use the Halo menu).

How do I build my menu and make it come up on a right-click (yellowButton, sigh)?

I currently have a CustomMenu and a handlerForYellowButtonDown: which calls the menu startup. The menu displays, but clicking on one of the selections has no effects. Any help or links greatly appreciated, thanks!

code snippets:

initialize
...
contextMenu := CustomMenu new title: 'Context Test Menu'.
contextMenu add: 'Clear - Erase Everything!' action: #menuStub.
contextMenu addLine.
contextMenu add: 'Do an Action' action: #menuStub:.

handlerForYellowButtonDown: event
Transcript show: 'yellowHandler';
show: Character cr.
contextMenu startUp

menuStub
Transcript show: 'menuStub';
show: Character cr

menuStub: something
Transcript show: 'menuStub: something';
show: Character cr

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怂人 2024-08-02 07:23:18

#invokeOn: 方法可用于指定目标:

menu := CustomMenu new.
menu add: 'make sound' action: #beep.
menu invokeOn: Beeper.

The #invokeOn: method can be used to specify a target:

menu := CustomMenu new.
menu add: 'make sound' action: #beep.
menu invokeOn: Beeper.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文