Bogdanp / racket-gui-easy

Declarative GUIs in Racket.
https://docs.racket-lang.org/gui-easy/index.html
134 stars 18 forks source link

"tabs" not working as per example/expected #55

Closed kouvas closed 2 months ago

kouvas commented 2 months ago

Tried to follow you demo example in racketcon 2021 with this code:

(define (run )
  (define @tab (obs "Booking"))
  (render
   (window
    #:title "Booker"
    #:size '(200 200)
    (tabs
     '("Booking" "Settings")
     (lambda (event choices selection)
       (case event
         [(select)
          (printf "tabs: ~s selected: ~s~n" choices selection)
          (obs-update! @tab (λ (_) (list-ref choices selection)))]))
     (case-view @tab
                [("Booking") 
                 (text "this is booking tab")]
                [("Settings")
                 (text "this is settings")]
                [else 
                 (text "unreachable")])))))

but when i switch tabs i get this error in the repl and cannot actually see expected text in settings tab:

(object:renderer% ...)
tabs: ("Booking" "Settings") selected: "Settings"
. . list-ref: index "Settings" is not an exact nonnegative integer
tabs: ("Booking" "Settings") selected: "Booking"
. . list-ref: index "Booking" is not an exact nonnegative integer
tabs: ("Booking" "Settings") selected: "Settings"
. . list-ref: index "Settings" is not an exact nonnegative integer

Based on demo, i would expect selection to be and integer but it's not. Am i doing something wrong?

Bogdanp commented 2 months ago

See the history note here. The selection argument is now the tab value itself rather than an index. So, you don’t need the list-ref and can just assign the selection to @tab.

kouvas commented 2 months ago

ooh just missed it. thanks