drracket

(define CHAR-CANVAS%
(class canvas%
(define/override (on-char evt)
(let ((c (send evt get-key-code)) (dc(send this get-dc)))
(send dc clear)
(print c)
(cond
((equal? c 'release)(void))
((member c '( #\a #\i #\u #\e #\o #\q #\é #\x))
(begin(set! tampon-key (cons c tampon-key)) (send dc draw-text (cadr (member (list->string (reverse tampon-key)) alphabet )) 30 30)
(send R-k-text insert (cadr (member (list->string (reverse tampon-key)) alphabet ))) (set! tampon-key '())))
((equal? c #;)(begin(send R-k-text insert “。”) (set! tampon-key '())))
((equal? c #,)(begin(send R-k-text insert “、”) (set! tampon-key '())))
((equal? c #()(begin(send R-k-text insert “「”) (set! tampon-key '())))
((equal? c #))(begin(send R-k-text insert " 」") (set! tampon-key '())))
((equal? c #&)(begin(send R-k-text insert “々”) (set! tampon-key '())))
((not(member c '(#\b #\c #\d #\f #\g #\j #\k #\m #\n #\p #\r #\i #\h #\t #\s #\w #\y #\a #\e #\o #\z #\u)))(void))
((begin (set! tampon-key (cons c tampon-key))(print tampon-key))))
))

(super-new)))

It works very well (it is for writing in hiragana katakana and other characters)
I want to add to this same canvas
a feature which tells me the position of the cursor on a text

is it possible? if yes
what is the code to add?

(define/override (on-char evt)…

Or do I need a another canvas?
in this case what will be my code?

(define/override (on-char evt)…

this in order to do something similar to a “RIKAICHAN”