[plt-scheme] vi mode and editor questions
One more thinng it seems that keys that are not
bound are propagated further , so your text% will
receive control-2 but not control-b , which is bound.
2008/11/23 Veer <diggerrrrr at gmail.com>:
> I also running linux ubuntu , while the above code as standalone
> program run as expected. I now see the point you are trying to
> make , indeed the canvas does not receive the proper key code ,
> i guess it is filtered by the drscheme frame.
>
>
> Here is another code for debug purpose when pressed
> "control-b" it produces:
>
> "frame%:on-subwindow-char :" : Control? #f key? control
> "frame%:on-subwindow-char :" : Control? #f key? control
> "canvas%:on-subwindow-char :" : Control? #f key? control
> "canavs%:on-char : " : Control? #f key? control
> "definition-text%:on-char : " : Control? #f key? control
> "frame%:on-subwindow-char :" : Control? #t key? b
> "frame%:on-subwindow-char :" : Control? #t key? b
> "canvas%:on-subwindow-char :" : Control? #t key? b
> "canavs%:on-char : " : Control? #t key? b
> "definition-text%:on-char : " : Control? #t key? b
> "frame%:on-subwindow-char :" : Control? #t key? release
> "frame%:on-subwindow-char :" : Control? #t key? release
> "canvas%:on-subwindow-char :" : Control? #t key? release
> "canavs%:on-char : " : Control? #t key? release
> "definition-text%:on-char : " : Control? #t key? release
> "frame%:on-subwindow-char :" : Control? #t key? release
> "frame%:on-subwindow-char :" : Control? #t key? release
> "canvas%:on-subwindow-char :" : Control? #t key? release
> "canavs%:on-char : " : Control? #t key? release
> "definition-text%:on-char : " : Control? #t key? release
>
> For code :
>
> #lang scheme/gui
> (require drscheme/tool)
>
> (provide tool@)
>
> (define (do-char who event)
> (printf
> "~s : Control? ~a key? ~a\n"
> who (send event get-control-down)
> (send event get-key-code)))
>
> (define tool@
>
> (unit
>
> (import drscheme:tool^)
>
> (export drscheme:tool-exports^)
>
> (define (phase1) void) ;(message-box "tool example" "phase1"))
>
> (define (phase2) void) ;(message-box "tool example" "phase2"))
>
> (drscheme:get/extend:extend-unit-frame
> (lambda (t%)
> (class t%
>
> (define/override (on-subwindow-char receiver event)
> (do-char "frame%:on-subwindow-char :" event)
> #f)
> (super-new))))
>
>
> (drscheme:get/extend:extend-definitions-canvas
> (lambda (t%)
> (class t%
>
> (define/override (on-subwindow-char receiver event)
> (do-char "canvas%:on-subwindow-char :" event)
> #f)
>
> (define/override (on-char evt)
> (do-char "canavs%:on-char : " evt)
> (super on-char evt))
> (super-new))))
>
>
> (drscheme:get/extend:extend-definitions-text
> (λ (t%)
> (class t%
>
> (define/override (on-char evt)
> (do-char "definition-text%:on-char : " evt)
> (super on-char evt))
>
> (define/override (on-default-char evt)
> (do-char "definition-text%:on-default-char : " evt)
> (super on-default-char evt))
>
>
> (super-new))) )))
>
>
> 2008/11/23 Jon Rafkind <workmin at ccs.neu.edu>:
>> Veer wrote:
>>>
>>> Hello,
>>>
>>> Correct me if i am wrong , but this is my understanding :
>>>
>>> If you override default on-char in editor-canvas% and not pass the
>>> event to text% then it
>>> will not receive the event. In any case text% is derived from object%
>>> and any key
>>> event has to be passed to it explicitly to it, which is what is done
>>> by default on-char
>>> method of editor-canvas%.
>>>
>>>
>>
>> The issue is not that the text% object receives the on-char, but that in the
>> editor-canvas's on-char I don't get key events with (get-control-down) as #t
>> and (get-key-code) as some character. It only seems to not work on X11.
>>>
>>> Key handling Code:
>>>
>>> (define (do-char who event)
>>> (printf
>>> "~s : Control? ~a key? ~a\n"
>>> who (send event get-control-down)
>>> (send event get-key-code)))
>>>
>>> (define frame
>>> (new frame%
>>> [label "Key Processing"]
>>> [width 300] [height 300]))
>>>
>>> (define ed%
>>> (class editor-canvas%
>>> (super-new)
>>>
>>> (define/override (on-char event)
>>> (do-char "ed%:on-char :" event)
>>> (send (send this get-editor) on-char event))
>>>
>>> (define/override (on-subwindow-char receiver event)
>>> (do-char "ed%:on-subwindow-char :" event)
>>> #f)))
>>>
>>> (define my-text%
>>> (class text%
>>> (super-new)
>>> (define/override (on-default-char event)
>>> (do-char "my-text%" event))))
>>>
>>> (define text-object (new my-text%))
>>> (define my-ed (new ed% [parent frame] [editor text-object]))
>>> (send frame show #t)
>>>
>>>
>>>
>>>
>>> On Sun, Nov 23, 2008 at 8:38 AM, Jon Rafkind <workmin at ccs.neu.edu> wrote:
>>>
>>>>
>>>> Robby Findler wrote:
>>>>
>>>>>
>>>>> On Sat, Nov 22, 2008 at 7:04 PM, Jon Rafkind <workmin at ccs.neu.edu>
>>>>> wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> I don't see the difference between my code and yours except that I'm
>>>>>> using
>>>>>> whatever editor the definitions window uses.
>>>>>>
>>>>>>
>>>>>
>>>>> I made a little tool (code below; I added a planet link and an info.ss
>>>>> file so drscheme would find the tool), and I still see the same (ie,
>>>>> good) behavior.
>>>>>
>>>>> Robby
>>>>>
>>>>> #lang scheme/gui
>>>>> (require drscheme/tool)
>>>>>
>>>>> (provide tool@)
>>>>> (define tool@
>>>>> (unit
>>>>> (import drscheme:tool^)
>>>>> (export drscheme:tool-exports^)
>>>>>
>>>>> (define phase1 void)
>>>>> (define phase2 void)
>>>>>
>>>>> (drscheme:get/extend:extend-definitions-text
>>>>> (λ (t%)
>>>>> (class t%
>>>>> (define/override (on-char evt)
>>>>> (printf "key-code ~s control ~s\n"
>>>>> (send evt get-key-code)
>>>>> (send evt get-control-down))
>>>>> (super on-char evt))
>>>>> (super-new))))))
>>>>>
>>>>>
>>>>
>>>> I just did an svn update to 4.1.3.1 (before I was using 4.1.2.2) and I
>>>> have
>>>> nothing in planet except for a link to the code above. I see the behavior
>>>> from before where ctrl-b does not register.
>>>>
>>>> I tried this on my other desktop machine which also runs linux+x11 and
>>>> drscheme 4.1.3.1 with the same behavior.
>>>> _________________________________________________
>>>> For list-related administrative tasks:
>>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>>
>>>>
>>
>>
>