Search code examples
windowsmalltalkvisualworks

How to create a window in 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

Solution

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