Hi!
This is my first post, so I hope I don't violate something here. If this does not fit here I hope you tell me so I can adapt.
I enjoy programming small tools with Racket, and I really like the easy to use gui Racket offers out of the box. The "standard library" is impressive, it's useful and the documentation is top!
However, I stumbled across a small issue (well, I can sail around it, but I don't think that should be necessary). I can append data to a list-box%, but not to a choice%.
#lang racket
(require racket/gui)
(define frame (new frame% [label "Example"]))
; a simple listbox
(define my-list-box
(new list-box%
[parent frame]
[label "my listbox:"]
[choices '()]))
; i can append an entry and assign a value to this entry
(send my-list-box append "hello" 123)
; later on i can access this data:
(send my-list-box get-data 0) ; this will return 123
; now, a choice%
(define my-choice
(new choice%
[parent frame]
[label "select something:"]
[choices '()]))
#|
this does not work:
(send my-choice append "other hello" 123)
it throws:
-append method in basic-list-control%: arity mismatch;
the expected number of arguments does not match the given number
expected: 1
given: 2
I can only do (send my-choice append "whatever")
|#
(send frame show #t)
I like to use the appended data to store perhaps table id's.
At the moment I just use list-box% instead of choice%, because I'm lazy to sail around.
The UI gets a bit hideous, but that's no matter.
But I'm curious, now, my question:
How would you implement such a functionality?
A in memory table that maps values to choice items? Inherit choice% and do it there? That would be my first thoughts, but I would like to get other opinions too.
Thank you very much for your time!