Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Checkboxes in menu items #51

Closed
cloudrac3r opened this issue Feb 28, 2024 · 2 comments · Fixed by #52
Closed

Feature request: Checkboxes in menu items #51

cloudrac3r opened this issue Feb 28, 2024 · 2 comments · Fixed by #52

Comments

@cloudrac3r
Copy link
Contributor

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?)
@Bogdanp
Copy link
Owner

Bogdanp commented Mar 1, 2024

I think this would be nice to add, but I'd prefer to add a new checkable-menu-item view to avoid overloading the menu-item action. Would you like to work on that? If not, I'll do it in the coming weeks.

@cloudrac3r
Copy link
Contributor Author

I created #52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants