[plt-scheme] GUI editor simple example

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Jul 4 09:47:00 EDT 2009

At Sat, 4 Jul 2009 01:44:42 -0600, Hugh Myers wrote:
> Given:
> 
> (define f (new frame% [label "Simple Edit"]
>                         [width 200]
>                         [height 200]))
>   (define c (new editor-canvas% [parent f]))
>   (define t (new text%))
>   (send c set-editor t)
> 
> How do I control the initial font?

Setting the font is more complicated than it should be. You have to
create a `style-delta%' (which has a poor API), and then apply the
style delta with `change-style'.

For example, to change the font to size 20:

 (send t change-style (make-object style-delta% 'change-size 20))

To set the font to "Times":

 (send t change-style (send (make-object style-delta%)
                            set-delta-face "Times"))

> How do I insert a line of text? 

(send t insert "Hello\n")

> Lines?

(send t insert "Hello\n")
(send t insert "Goodbye\n")



Posted on the users mailing list.