Skip to content

Instantly share code, notes, and snippets.

@jgreco
Created September 8, 2019 22:45
Show Gist options
  • Save jgreco/1a56579caf19d12d3328167727a3a42f to your computer and use it in GitHub Desktop.
Save jgreco/1a56579caf19d12d3328167727a3a42f to your computer and use it in GitHub Desktop.
#lang racket/gui
(require framework)
(define swapping-tab-panel%
(class tab-panel%
(inherit get-selection set-selection set)
(super-new [callback
(lambda (b e)
(when (eq? 'tab-panel (send e get-event-type))
(send swapper-panel active-child
(vector-ref children-vec (get-selection)))))])
(define children-vec '())
(define swapper-panel
(new (panel:single-mixin panel%)
[parent this]))
(define/public (get-container) swapper-panel)
(define/public (set-children children)
(for ([c children]) (send c reparent swapper-panel))
(set (map (lambda (c) (send c get-label)) children))
(set-selection 0)
(send swapper-panel active-child (first children))
(set! children-vec (list->vector children)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment