Click the "add page" button to dock a new component to the workspace.
Click the "change mode" button to change the workspace's navigation mode from stack to tabs.
Click the "add page button". The workspace will not correctly remove the dynamic components of the previous page:
This only seems to happen when the workspace starts in Stack navigation mode. Starting it in tab mode, or starting it in stack mode and changing to tab mode before docking anything prevents it from happening.
Using some print outs it appears that after the initial component has been docked and the user switching modes to tab navigation. The component is undocked and redocked. However for some reason this re-dock is not ran inDynamicComponent modes so the button is not marked for removal.
This has really stumped me.
I am using the latest 2.0.0 Snapshot.
package org.example
import tornadofx.*
import java.util.*
class MyApp : App(MyWorkspace::class) {
}
class MyWorkspace : Workspace("rere", NavigationMode.Tabs) {
init {
primaryStage.width = 1200.0
primaryStage.height = 800.0
with(leftDrawer) {
item(expanded = true) {
vbox {
button("change mode") {
action {
if (workspace.navigationMode == NavigationMode.Stack) {
workspace.navigationMode = NavigationMode.Tabs
} else {
workspace.navigationMode = NavigationMode.Stack
}
}
}
button("add page") {
action {
workspace.dockInNewScope<Page>()
}
}
}
}
}
}
}
class Page : View() {
val myID = UUID.randomUUID().toString().substring(0..5)
override fun onDock() {
println("Docking $myID")
with(workspace) {
button(myID)
}
}
override val root = borderpane {
center = hbox {
button("docked pages") {
action {
println("docked component is now ${workspace.dockedComponent}")
}
}
}
}
init {
title = myID
}
override fun toString(): String {
return title
}
}
fun main() {
launch<MyApp>()
}
Run the following minimal example:
This only seems to happen when the workspace starts in Stack navigation mode. Starting it in tab mode, or starting it in stack mode and changing to tab mode before docking anything prevents it from happening.
Using some print outs it appears that after the initial component has been docked and the user switching modes to tab navigation. The component is undocked and redocked. However for some reason this re-dock is not ran inDynamicComponent modes so the button is not marked for removal.
This has really stumped me.
I am using the latest 2.0.0 Snapshot.