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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jan 19 07:29:08 EST 2009

Sorry for the delay --- this is now fixed in SVN.

At Sun, 18 Jan 2009 13:22:08 -0700, "Doug Williams" 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
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.