[plt-scheme] HTDP Exercise 22.3.3. - Hint needed
You will need a callback for each button. When the event happens the
callback
to this button is triggered. Do it manually for each button and then
follow the
design recipe from this section to abstract over the button creation
process in
general
(map (lambda (row) (map make-button row)) pad)
and the button callback function in particular. -- Matthias
P.S. I promise it will be enlightening.
On Saturday, November 29, 2003, at 10:30 AM, Guenther Schmidt wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Hi,
>
> I've developed the code following code but I have one problem: How do
> I identify the button that was pressed?
>
> When I specify the callback function to a button do I need to pass
> specific arguments, in short: I don't know how it's done.
>
> ;; model
>
> (define pad
> '((1 2 3)
> (4 5 6)
> (7 8 9)
> (\# 0 *)))
>
> (define pad2
> '((1 2 3 +)
> (4 5 6 -)
> (7 8 9 *)
> (0 = \. /)))
>
>
> ;; view
>
> (define md (make-message "n"))
>
> (define (pad->gui title a-list)
> (cons
> (list (make-message title))
> (cons (list md)
> (traverse a-list))))
>
> (define (traverse a-list)
> (cond
> ((empty? a-list) empty)
> ((list? a-list)
> (cons (traverse (first a-list))
> (traverse (rest a-list))))
> (else
> (make-button
> (cond
> ((symbol? a-list) (symbol->string a-list))
> (else (number->string a-list)))
> test))))
>
> ;; controller
>
> (define (test e)
> (draw-message md "2"))
>
> (create-window (pad->gui "PHONE" pad))
>
>
>
> Cheers
>
> Guenther
>