Google

link="#009900" vlink="#007700" alink="#cc0000"> Teachpacks for How to Design Programs

Arrows GUI


arrow-gui.ss

The teachpack arrow-gui.ss implements three functions:

  • control : -> symbol
    to read out the current state of the message field
  • view : (union string symbol) -> true
    to display its argument in the message field
  • modelT = (button% event% -> true)
    connect : modelT modelT modelT modelT -> true
    to connect four controllers with the four directions in the arrow window
  • Example:

    > (define (make-model dir)
       (lambda (b e)
         (begin
           (view dir)
           (printf "~a ~n" (control)))))
    
    > (connect
       (make-model "left")
       (make-model "right")
       (make-model "up")
       (make-model "down"))  
    
    Now click on the four arrows. The message field will contain the current direction, the print-out the prior contents of the message field.