Previous Step: Add application resources to your project.
Back to Top

# Create an Application class

Now you are ready to actually write some Smalltalk code. In this tutorial you will only write a small amount of code, but in a real project most of your time will be spent writing Smalltalk code (rather than getting things set up as you did in the last few pages).

The package forms.st which you installed contains a lightweight application framework which takes most of the tedium out of writing PalmOS applications. There are classes such as Button and TextField which represent PalmOS user interface elements, and an Application class which implements an event loop and methods for managing bindings between PalmOS and Smalltalk.

The first step is to create a subclass of Application for your new application. Open a Class Browser and select the Application class. Use the menu option Class/Make subclass... to create a new subclass; name the new class TutorialApplication. This adds a new class to your project, which you can confirm by opening a Package Browser and selecting the tutorial.st package.

To tell PalmOS to use the form layout you defined earlier, you must override the class-side method `#formID`. Make sure the new TutorialApplication class is selected in the Class Browser, then set the Instance/Class tab in the upper right to Class. You can now add class-side methods.

Right-click in the upper-right pane and select New method from the context menu. The source code pane at the bottom clears, allowing you to enter a new method. Type the following into the source code pane, then hit Ctrl-S to save it:

    formID
         ^3000.

This tells the application framework to use Form ID 3000 for this Application subclass.

This is the only required method; the others are optional. To actually launch the application you must override the method `#start` on the class side of the class Smalltalk. Replace the default method definition with the following:

    start
        TutorialApplication show.

Now you are ready to test the application on the PalmPilot.

Next Step: Generate an executable application.
Back to Top