[plt-scheme] Control+Backspace as backward-kill-word?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Jul 8 11:29:15 EDT 2009

The second one below maps control+delete successfully for me. I think
something might be wrong with the keymap% class and its handling of
"backspace", since this doesn't work either (run the code and hit
control-backspace or just backspace; expect to see "ff" appear, but
backspacing happens; you do get two "f"s when you type "f", however).

(define f (new frame% [label ""] [width 100] [height 100]))
(define k (new keymap%))
(define t (new text%))
(define ec (new editor-canvas% [parent f] [editor t]))
(send t set-keymap k)
(send k add-function "two-fs"  (λ (x y) (send x insert "ff")))
(send k map-function "c:backspace" "two-fs")
(send k map-function "backspace" "two-fs")
(send k map-function "f" "two-fs")
(send ec focus)
(send f show #t)

The following code does print out #\backspace, so perhaps something is
going wrong in the keymap code.

(define f (new frame% [label ""] [width 100] [height 100]))
(define c
  (new (class canvas%
         (define/override (on-char evt)
           (printf "~s\n" (send evt get-key-code))
           (super on-char evt))
         (super-new [parent f]))))
(send c focus)
(send f show #t)

Robby

2009/7/8 Elena Garrulo <egarrulo at gmail.com>:
> Hello,
>
> I'd like to have Control+Backspace remapped as backward-kill-word. Following
> advice found over the net, I've tried both these snippets of code, which not
> work:
>
> #lang s-exp framework/keybinding-lang
> (keybinding "c:del" (λ (editor evt) (send editor backward-kill-word)))
>
> #lang s-exp framework/keybinding-lang
> (keybinding "c:del" (lambda (editor event)
>                     (send
>                         (send editor get-keymap)
>                         call-function
>                         "backward-kill-word"
>                         editor event #t)))
>
> Any help? Thanks.
>
>
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.