How to create a window in smalltalk

落爺英雄遲暮 提交于 2019-12-11 03:26:10

问题


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

回答1:


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.

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.

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.




回答2:


You can use this:

ScheduledWindow new
    label: 'Hello';
    open

Or to open larger:

ScheduledWindow new
    label: 'Hello';
    openIn: (20@20 extent: 300@300)

I suspect, however, that this isn't what you really want to do since it's hard to work with a window that's built this way. Can you explain more about what you want to do?



来源:https://stackoverflow.com/questions/13295815/how-to-create-a-window-in-smalltalk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!