[plt-scheme] editor object.

From: Jon Philpott (jon at uv.net)
Date: Tue Jan 14 11:29:05 EST 2003


I'm trying to create an custom edit object, so that when a user
types, for example "hello [cruel] world" that the part in
the [] will be underlined and have a clickback associated with it.

I've started off by trying out a few tests as I've not used any
of the GUI tools in drscheme at all:

(define my-text%
   (class text%
     (inherit last-position get-text)
     (override on-insert)
     (define on-insert
       (lambda (start len)
         (printf "~a" (get-text start (+ start len)))))
(super-instantiate ())))

I was hoping that each time a user inserts a character that it would
display that character on the console. However, what actually happens
is this;
	1. the first time a character is inserted, nothing is
	2. anytime any following characters are inserted, only the
	the first character is displayed, for example, if i type
	"hello cruel world" it display "h" everytime i display a

I added some debug code into this so each time on-insert was called
it displayed the values of "start" and "len", and then did,
(send my-text-box get-text [value of start] [value of start + len])
for each character inserted, which returned the correct character.

Any idea where i'm going wrong?


Posted on the users mailing list.