Adding the method open
The first method we will work on is the open method. This method is responsible for opening the calculator window and setting up the widgets needed to implement the user interface.
1. Ensure that the method radio buttons are set to instance and public.
2. From the Methods pop-up menu, select New Method Template.
3. The text pane changes to a new method template. This is to remind you of the form for the definition of a method.
4. Delete the method template from the text pane.
5. Type in the following code:
open
"Open a new instance of STCalculator."
| shell form |
shell := CwTopLevelShell
createApplicationShell: 'Calculator'
argBlock: nil.
shell realizeWidget.
6. Save the method. (You can use the pop-up menu, the accelerator keys, or the File menu.)
 
Tip
If syntax error or a similar phrase is displayed, check for a misspelled word, a missing word, or missing punctuation. (Ensure you erase the phrase.)
If a debugger window opens, read the message in its top pane. It should indicate how you can correct the method open. Make any needed corrections in the method; then pop up the menu and select Save again. For more information on the debugger, see “Debugging code”. in the Smalltalk User Guide.
Now is a good time to save your image. From the Transcript, Choose Save Image... from the File pull down menu.
Last modified date: 07/23/2020