[racket] separate keybindings for interaction vs. definition window
Here's a more detailed reply. This is the code you want, I believe:
#lang s-exp framework/keybinding-lang
(require drracket/tool-lib)
(define (rebind key function)
(keybinding
key
(lambda (editor event)
(send
(send editor get-keymap)
call-function
(if (is-a? editor drracket:rep:text<%>)
function
original-function)
editor event #t))))
(rebind "down" "put-next-sexp" "next-line")
(rebind "up" "put-previous-sexp" "previous-line")
Note that I dropped the colon; otherwise you'd have to fix up the
bindings for shift-up, etc etc etc too.
Robby
On Fri, Jan 14, 2011 at 6:54 AM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> Check and see if the text% object is drracket:rep:text<%>, I believe.
>
> Robby
>
> On Thu, Jan 13, 2011 at 11:43 PM, Benjamin Rahn <benjamin.rahn at gmail.com> wrote:
>> I'm creating some custom key bindings. Is there a way to make the key
>> bindings different for the interaction frame vs. the definitions window?
>>
>> Specifics: I would like to use the up/down keys (with no modifiers) to move
>> back and forth through expressions that have been previously entered into
>> the interaction window. I have a custom keybindings file (below) does this.
>>
>> However, it simultaneously disables the up/down arrows in the definitions
>> window, which is of course a deal-breaker.
>>
>> Is there a way I can use these keybindings in the interaction window, but
>> leave the definitions window behavior unchanged?
>>
>> Thanks!
>>
>> -Ben
>>
>>
>>
>> ***********
>>
>> #lang s-exp framework/keybinding-lang
>>
>> ; I'm sure there's a less verbose way to achieve the same results, comments
>> welcome.
>>
>> (keybinding ":down" (lambda (editor event)
>> (send
>> (send editor get-keymap)
>> call-function
>> "put-next-sexp"
>> editor event #t)))
>>
>> (keybinding ":up" (lambda (editor event)
>> (send
>> (send editor get-keymap)
>> call-function
>> "put-previous-sexp"
>> editor event #t)))
>>
>> _________________________________________________
>> For list-related administrative tasks:
>> http://lists.racket-lang.org/listinfo/users
>>
>