[racket] Using GUI editor

From: Alan Johnsey (a.johnsey at cox.net)
Date: Fri Sep 20 21:40:58 EDT 2013

Thanks. That will do for now, but it remains a mystery to me why my approach
doesn't work.

-Alan

 

 

  _____  

From: Matthias Felleisen [mailto:matthias at ccs.neu.edu] 
Sent: Friday, September 20, 2013 10:17 AM
To: Alan Johnsey
Cc: 'Racket Mailing List'
Subject: Re: [racket] Using GUI editor

 

 

On Sep 20, 2013, at 1:05 PM, Alan Johnsey wrote:





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

 

 

Do you want this

 

 (send t insert "Use this window for making notes" 10 10)

 

instead of the below? 

 





 

(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)

 

 

____________________
 Racket Users list:
 http://lists.racket-lang.org/users

 

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

Posted on the users mailing list.