See also ''PLT MrEd: Graphical Toolbox Manual Chapter 5 Drawing Toolbox Overview''
Here is a simple example of;
putting an image on a canvas
getting a mouseclick
getting the colour of the canvas at the point of the click.
I put it here because, while there are good examples in the MrEd (gui) manual, this is one that isn't covered.
Use DrScheme language MrEd
;; obtain a bitmap and stick it into a bitmap dc
(defineplt
(make-objectbitmap% (build-path (collection-path"icons")
"plt.gif")))
(definebm
(newbitmap-dc% [bitmapplt]))
;; --- set up a frame with a canvas in which to display this image
(defineframe
(newframe% [label"Test for Linda"]
[width (sendpltget-width)] [height (sendpltget-height)]))
(definecanvas (new;; --- create a class on the fly that overrides the callback for
;; --- mouse events in a canvas; you could name it, if needed
(classcanvas%;; Event -> Void
;; act on each mouse event
(define/override (on-evente)
(definekind (sendebutton-down?))
(definex (sendeget-x))
(definey (sendeget-y))
(definec (newcolor%))
(whenkind
(if (sendbmget-pixelxyc)
(printf"color is ~s ~s ~s\n"
(sendcred) (sendcgreen) (sendcblue))
(printf"no color"))))
(super-new))
;;--- provide a frame and a paint method for displaying plt.gif
[parentframe]
[paint-callback (lambda (edc) (senddcdraw-bitmapplt00))]))
;; --- run program run
(sendframeshow#t)