Previous Step: Generate an executable application.
Back to Top

Create bindings to PalmOS widgets

The application framework in Pocket Smalltalk provides an easy way to associate Smalltalk objects with PalmOS controls. To specify an action to be performed when the "Push Me" button is tapped, you need to override the #createComponents method in the TutorialApplication class (make sure the Class/Instance tab is set to Instance). Define it as follows:

createComponents
    self add: Button id: 4000 name: nil aspect: #buttonClicked.
The message #add:id:name:aspect is the main way to create bindings between Smalltalk objects and PalmOS controls. The first argument is the class of the Smalltalk object to create. The id: argument is the control ID you specified in the form layout. The name: argument can be a symbol which names the object for later reference. This button does not need a name so this argument is nil. Finally, the aspect: argument is interpreted differently depending on what kind of form control is being defined. The full set of aspect interpretations is specified in the User's Manual, but for a button the aspect is simply a selector that is sent to the Application instance when the button is clicked.

Since you specified #buttonClicked as the aspect of the button, you must create a #buttonClicked method in the TutorialApplication class (Instance side). Define it as:

buttonClicked
    Form notify: 'Hello, world!'.
The Form notify: method will pop up a dialog with the message.

Now that the binding is created, try re-generating the .prc (System/Generate code in the Launcher) and reloading it into your PalmPilot. This time the message should be displayed when you tap the button.

Congratulations! You have written your first application in Pocket Smalltalk. You have also been introduced to many of the components of the development environment. Your next steps should be to read the User's Manual and experiment with modifications to this tutorial application.


Back to Top