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

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Sun Jan 18 15:22:08 EST 2009

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%
    (min-width 100)
    (min-height 100)))

(define the-menu-bar
  (instantiate menu-bar%

(define the-test-menu
  (instantiate menu%
    ("&Test" the-menu-bar)))

(define the-checkable-menu-item
  (instantiate checkable-menu-item%
    ("&Check" the-test-menu)
     (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.4 prerelease candidate) on Windows XP.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090118/c2dbe1f1/attachment.html>

Posted on the users mailing list.