[plt-scheme] redirecting all keyboard to a widget (MrEd)

From: Ivanyi Peter (pivanyi at freemail.hu)
Date: Mon Aug 9 09:12:46 EDT 2004

Hi,

In my application written in MrED I would like to redirect all keyboard
to a widget and at the same time I would like to look out for the
ENTER, SPACE, TAB, ESCAPE characters when I perform some action.
What I have tried is to create a new class
(something like this)

(define my-window%
  (class frame%
    (define/override (on-subwindow-char w e)
      (let ( (c (send e get-key-code)) )
        (cond
          ((eq? c 'escape) .... do somthing .... #t)
          ((and (char? c) (char-whitespace? c)) .... do something ... #t)
          ((member c '(#\backspace #\rubout))
           ... do proper deletion
          )
          ( (char? c)
            (send (send my-text get-editor) insert c)
            #t
          )
          ( else #f )
        )))
    (super-instantiate ())
  )
)

However  I have problem with the backspace and the delete keys. The
reason for the special handling because I cannot 'insert' them and 
somehow I think that this solution is a little bit clumsy. 
My other idea is related to keymaps. In framework/keymap.ss I 
have found a part where the call-function method is used e.g:

(let ((kmap (send editor get-keymap)))
  (send kmap call-function "delete-next-character" editor event #t)
  ...
)

But there is no documentation about the delete-next-character or the 
delete-previous-character function and I did not find them. (I assume 
they are defined in wx.) Are these standard, can I also use them?
If not, what else can I use?

Can somebody direct me to the right direction so I can do it in a 
nice and clean way?

Thanks in advance.

Peter Ivanyi



Posted on the users mailing list.