[plt-scheme] MrEd Learning

From: Alex Peake (apeake at comac.com)
Date: Sun Aug 17 00:48:19 EDT 2003

I am trying out MrEd - following the manual.

In 2. Windowing Toolbox Overview, the example is:

;; Make a frame by instantiating the frame% class
(define frame (instantiate frame% ("Example")))
;; Make a static text message in the frame
(define msg (instantiate message% ("No events so far..." frame)))
;; Make a button in the frame (using keyword-based arguments, for demonstration)
(instantiate button% () (label "Click Me") (parent frame)
;; Callback procedure for a button click
(callback (lambda (button event) (send msg set-label "Button click"))))
;; Show the frame by calling its show method
(send frame show #t)

;; Derive a new canvas (a generic drawing window) class to handle events
(define my-canvas%
  (class canvas% ; The base class is canvas%
;; Declare overrides:
(override on-event on-char)
;; Define overriding method to handle mouse events
(define on-event (lambda (event) (send msg set-label "Canvas mouse")))
;; Define overriding method to handle keyboard events
(define on-char (lambda (event) (send msg set-label "Canvas keyboard")))
;; Call the superclass initialization (and pass on all init args)
(super-instantiate ())))
;; Make a canvas that handles events in the frame
(instantiate my-canvas% (frame))

The following text says: Clicking on the canvas calls on-event. While the canvas has the keyboard
focus, typing on the keyboard invokes the canvas’s on-char method.

However, this never happens - the message never gets changed to "Canvas keyboard"?


In 8. Editor Toolbox, the example is:

(define f (instantiate frame% ("Simple Edit" #f 200 200)))
(define c (instantiate editor-canvas% (f )))
(define t (instantiate text% ()))
(send c set-editor t)
(send f show #t)

(define mb (instantiate menu-bar% (f )))
(define m-edit (instantiate menu% ("Edit" mb)))
(define m-font (instantiate menu% ("Font" mb)))
(append-editor-operation-menu-items m-edit)
(append-editor-font-menu-items m-font)

The following text says: The user can also insert an embedded editor by selecting Insert Text from
the Edit menu;

However, there is no  Insert Text choice?



Posted on the users mailing list.