Skip to Content

What is the preferred way to add code for handling a push-button click or key press?

Estimated Reading Time: 1 Minutes
There are 3 ways to tie code to the action of a user hitting a push-button.

From most preferred to least preferred they are:

  1. Double-click on the control to add a Link To paragraph (or add it by clicking on Link To in the properties view), and enter a number for the exception-value property
  2. Add a cmd-clicked exception paragraph (automatically adds an Exception procedure)
  3. Add a cmd-clicked event paragraph (automatically adds an Event procedure)
Functionally, the difference between Link-To and Cmd-Clicked procedures is that Link-To allows you to manually assign an exception value. You do this by entering the number of your choice (values greater than 100 are common) in the exception-value property field. If I enter an exception-value of 1000 then the generated code looks something like this:

       is-screen-3-proc.
           perform until exit-pushed
              accept screen-3
              on exception perform is-screen-3-evaluate-func
              end-accept
           end-perform.
           destroy window-handle.
           initialize key-status.
       is-screen-3-evaluate-func.
           evaluate true
           when exit-pushed
              perform is-screen-3-exit
           when event-occurred
              if event-type = cmd-close
                 perform is-screen-3-exit
              end-if
              when key-status = 1000
                 perform screen-3-pb-2-link-to
           end-evaluate.
           move 1 to accept-control.
       is-screen-3-exit.
           set exit-pushed to true.

        screen-3-pb-1-link-to.
             modify screen-3-lb-1 item-to-add "Hello".
            .

With manually assigned exception values it is possible to have a menu entry and/or function key generate the same exception value so that the user could perform the function in more than one way. In fact, "Link To" is the preferred way to specify a paragraph to execute when the user selects a menu entry.

What is the preferred way to add code for handling a push-button click or key press?

Powered by PHPKB (Knowledge Base Software)