mouse handlers must have the contract
; function-name : image (old)
; number (mouse-x) number (mouse-y)
; event
; -> image (new)
Mouse handlers are installed with (on-mouse function-name ).
draw handlers must have the contract
; function-name : image (current) -> image
and are installed with (on-draw function-name width height ). If you leave
out the width and height, the animation window will be the size and shape of the
result the first time the draw handler is called.
Function skeleton:
(define (move-right-10-on-mouse picture x y mouse-event)
...)
Fill in the inventory:
(define (move-right-10-on-mouse picture x y mouse-event)
; picture image
; x number
; y number
; mouse-event whatever this is
...)
Fill in the body: We already know how to use picture to get the desired answer.
The other three parameters are of no interest to us, so we just won’t use them. Thus we
can write
(define (move-right-10-on-mouse picture x y mouse-event)
; picture image
; x number
; y number
; mouse-event whatever this is
(beside (rectangle 10 0 "solid" "white") picture)
)
Now that we have the move-right-10-on-mouse function,
we can use it in an animation:
(big-bang pic:calendar
(on-draw show-it 500 100)
(on-mouse move-right-10-on-mouse))