Created
September 8, 2019 22:45
-
-
Save jgreco/1a56579caf19d12d3328167727a3a42f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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