[racket] Problem with on-subwindow-event

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Sep 24 19:57:46 EDT 2012

When I run this on the mac, I don't see any enter events, which seems
strange. But my initial reaction to your question was that you need to
use the 'r' argument.

Robby

On Mon, Sep 24, 2012 at 5:00 PM, Kieron Hardy <kieron.hardy at gmail.com> wrote:
> Hi all,
>
> Considering the program below, does anyone know:
>
> - Why do I get 3 enter messages when moving the mouse cursor into the frame,
> and 2 enter messages when moving the mouse cursor into the list-box%?
>
> - If (as I suspect) there is a call to on-subwindow-event for every
> sub-component of a widget (i.e. 3 sub-components for a frame%, 2 for a
> list-box%), how should I filter so that I only process the event once for
> each component?
>
> Thanks in advance,
>
> Kieron.
>
> ****
>
> #lang racket
>
> (require racket/gui)
>
> (define my-frame%
>   (class frame%
>     (super-new)
>     (define/override (on-subwindow-event r e)
>       (when (equal? (send e get-event-type) 'enter)
>         (printf "enter ~a~n" (object-name r))))))
>
> (define f (new my-frame%
>                [label "test list-box"]
>                [width 400]
>                [height 200]))
>
> (define l (new list-box%
>                [parent f]
>                [label "options"]
>                [choices (list "apple" "pear" "cherry")]
>                [stretchable-width #f]
>                [stretchable-height #f]))
>
> (send f show #t)
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

Posted on the users mailing list.