如何在smalltalk中创建一个窗口 [英] How to create a window in smalltalk

查看:26
本文介绍了如何在smalltalk中创建一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示一个窗口,但我不断收到一条消息无法理解错误.片段:

I am trying to make a window show up, but i keep getting a message not understood error. The snippet:

Window new
  label: 'Hello';
  open

推荐答案

好的,对于这样的游戏,您想使用自定义控件.您首先为您的游戏创建 View 的子类并覆盖 displayOn: 方法以显示视图.您可以使用 ViewHolder 将视图添加到 UIPainter 画布.将 View: 属性设置为返回自定义视图的方法的名称.

Ok, for a game like that you want to use a custom control. You start by creating a subclass of View for your game and override the displayOn: method to display the view. You can add the view to the UIPainter canvas using a ViewHolder. Set the View: property to be the name of a method that returns your custom view.

要拦截鼠标点击,您需要为您的视图设置一个自定义控制器.您将对 Controller 或其子类之一进行子类化以创建 Controller.视图中名为 defaultControllerClass 的方法返回控制器类的名称.在控制器中,您可以拦截鼠标事件.

To intercept mouse clicks, you'll need to have a custom controller for your view. You'll subclass Controller or one of its subclasses to create the Controller. A method called defaultControllerClass in the View returns the name of the controller class. In the controller, you can intercept mouse events.

我建议您加载一个示例游戏以开始使用.打开包裹管理器,然后从列表中选择玩具.你应该在那里看到蜘蛛纸牌.这是一个为 VisualWorks 编写的游戏,它显示一个自定义视图,在该视图上做一些简单的动画,并拦截鼠标事件.这应该是一个很好的例子.

I suggest that you load an example game to get you started. Open the Parcel Manager, and select Toys from the list. You should see SpiderSolitaire there. This is a game written for VisualWorks that displays a custom view, does some simple animation on that view, and intercepts mouse events. That should serve as a good example to use.

这篇关于如何在smalltalk中创建一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆