[racket] Using GUI editor

From: Alan Johnsey (a.johnsey at cox.net)
Date: Fri Sep 20 13:05:33 EDT 2013

It looks like I've stumbled into another area where I'm lacking a basic
understanding of what's going on.  I'm trying to use the built-in editor in
the gui package, but I need to put some initial content into the editor
window. When I put the following in the editor pane and run it, I get the
gui editor, but not the text. When I then

simply put the last line into the interactions window and execute it, I get
the text in the gui editor window as desired. Why? What do I need to do to
programmatically modify the text in the gui window?

-Alan

 

#lang racket/gui

(define f (new frame% [label "Notes"]

                      [width 400]

                      [height 600]))

(define c (new editor-canvas% [parent f]))

(define t (new text%))

(send c set-editor t)

(send f show #t)

 

(define mb (new menu-bar% [parent f]))

(define m-edit (new menu% [label "Edit"] [parent mb]))

(define m-font (new menu% [label "Font"] [parent mb]))

(append-editor-operation-menu-items m-edit #f)

(append-editor-font-menu-items m-font)

 

; above pretty much straight out of the Design Doc

 

(define dc (send c get-dc))

(send dc set-scale 1 1)

(send dc set-text-foreground "blue")

(send dc draw-text "Use this window for making notes" 0 0)

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130920/36346b21/attachment.html>

Posted on the users mailing list.