[plt-scheme] Re: Question about Shortcuts on Checkable Menu Items

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Sun Jan 18 19:38:51 EST 2009

I also tested the code on Mac OS X and Linux (Ubuntu AMD64) and got the same
result.

On Sun, Jan 18, 2009 at 1:22 PM, Doug Williams <m.douglas.williams at gmail.com
> wrote:

> I am trying to use a shortcut for a checkable menu item and I don't
> understand the behavior. Consider the following trivial gui program.
>
> #lang scheme/gui
>
> (define the-frame
>   (instantiate frame%
>     ("Test")
>     (min-width 100)
>     (min-height 100)))
>
> (define the-menu-bar
>   (instantiate menu-bar%
>     (the-frame)))
>
> (define the-test-menu
>   (instantiate menu%
>     ("&Test" the-menu-bar)))
>
> (define the-checkable-menu-item
>   (instantiate checkable-menu-item%
>     ("&Check" the-test-menu)
>     (callback
>      (lambda (checkable-menu-item event)
>        (printf "is-checked? = ~a~n"
>                (send checkable-menu-item is-checked?))))
>     (shortcut #\C)))
>
> (send the-frame show #t)
>
> If I select the check menu item with the mouse or with the alt keys (alt-T,
> alt-C in this case), it toggles and prints as expected. If I select it using
> the shortcut key (cntl-C in this case), the callback runs but the value
> isn't toggled. Is this the 'correct' behavior? [If so, I assume I need to
> check the event type and toggle the check myself.]
>
> I'm running Version 4.1.3.900 (4.1.4 prerelease candidate) on Windows XP.
>
> Thanks,
> Doug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090118/cbc28040/attachment.html>

Posted on the users mailing list.