[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/6fb73475/attachment.html>