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

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Aug 9 09:15:52 EDT 2004

I don't know that there is a clean way to do that, since it goes
against the design of the underlying toolkits. How about just sending
the keyboard focus to the place where you want to send the keystrokes
(with the `focus' method)?

Robby

At Mon, 9 Aug 2004 15:12:46 +0200 (CEST), Ivanyi Peter wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> 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.