Closed
Description
Seems to be supported by racket/gui: https://docs.racket-lang.org/gui/checkable-menu-item_.html
I imagine the API would look something like:
(define/obs @high-contrast? #f)
(menu "View"
(menu-item "High Contrast"
(λ (checked) (:= @high-contrast? checked)) ; <-- adding a checked parameter
#:checked @high-contrast? ; <-- #:checked observable
#:enabled? #t))
The callback action could do anything (but most likely be used to set an observable), and likewise, updating the #:checked observable would update the visible state of the menu item.
The function could be named menu-item
or checkable-menu-item
, but I think it's cuter to have checkable and non-checkable items both be called menu-item
because then all the menu labels will align in the source code:
(menu-item "Debug..." ; <-- the left edge of this string...
(λ () (show-debug-window)))
(menu-item "High Contrast" ; <-- ...lines up with the left edge of this string!
(λ (checked) (:= @high-contrast? checked))
#:checked @high-contrast?)
Metadata
Metadata
Assignees
Labels
No labels