No callback when re-selecting in choice%
When using Racket 8.0 under Kubuntu 20.04 (Qt version 5.12.8, KDE Frameworks version 5.68.0), the callback function in choice% is not called when clicking on the already selected item, but only when clicking on a different item. I was not able to test on a different system, but as explained in this reddit post @sorawee tried the code on both Linux and Mac OS and was only able to reproduce the bug on the former.
This example reproduces the behavior:
#lang racket/gui
(define main-window (new frame% [label "Callback test"] [width 400] [height 400] [border 10]))
(new choice%
[label "Choice"]
[parent main-window]
[choices (list "Option A" "Option B" "Option C")]
[callback
(lambda (c e) (new message% [parent callback-log]
[label (string-append (symbol->string (send e get-event-type))
" event @"
(number->string (send e get-time-stamp)))]))])
(define callback-log
(new group-box-panel% [parent main-window]
[label "List of callback events:"]
[min-height 200]))
(send main-window show #t)
It might be interesting to consider rewording the documentation for choice%, since two slightly different criteria are given for when the callback is invoked. It first says (emphasis mine):
Whenever the selection of a choice item is changed by the user, the choice item’s callback procedure is invoked.
which implies that the newly selected item needs to be different from the previously selected one, yet a bit later it says:
The callback procedure is called (with the event type 'choice) when the user selects a choice item (or re-selects the currently selected item).
I am having the same problem; using Kubuntu as well