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

Add Tabs at Runtime #26

Closed
joerg-rade opened this issue Mar 27, 2019 · 2 comments
Closed

Add Tabs at Runtime #26

joerg-rade opened this issue Mar 27, 2019 · 2 comments

Comments

@joerg-rade
Copy link
Contributor

Hi Robert,

I would like to add tabs to TabPanel at runtime. Showcase.start() and TabPanel.addTab() suggest that this is not possible right now.

SubClassing didn't work out since TabPanel.content & nav are private.
How should I proceed?

Thanks in advance
Jörg

@rjaros
Copy link
Owner

rjaros commented Mar 27, 2019

It's definitely possible to add tabs at runtime. This code is working without any problems for me:

        val panel = tabPanel {
            addTab(tr("Blue panel"), Tag(TAG.DIV, " ", rich = true) {
                background = Background(Col.BLUE)
                height = 40.px
            })
            addTab(tr("Green panel"), Tag(TAG.DIV, " ", rich = true) {
                background = Background(Col.GREEN)
                height = 40.px
            })
        }
        var counter = 3
        button("add new tab").onClick {
            panel.addTab("Tab $counter", Tag(TAG.DIV) {
                label("Any dynamic content of tab number ${counter++}")
            })
        }

@joerg-rade
Copy link
Contributor Author

Thanks - it works.
I don't know anymore where I got lost ;-)

A sample where creating and adding the tab object to the panel are split in two steps could help newbies like me.

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

No branches or pull requests

2 participants