User's Guide


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 push buttons are set to instance and public.
  2. From the Methods 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.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]