Hey there! Maybe someone can help me figure this ...
# tornadofx
f
Hey there! Maybe someone can help me figure this out:
Copy code
class MyApp : App(Workspace::class, Styles::class) {
    init {
        with (workspace) {
            // This does NOT remove the forwardButton
            forwardButton.removeFromParent()
            // This does
            header.items.remove(forwardButton)
            // And so does this
            header.getChildList()?.remove(forwardButton)
        }
    }
}
However, the implementation of
removeFromParent()
says
Copy code
when (this) {
        […]
        is Node -> {
            (parent?.parent as? ToolBar)?.items?.remove(this) ?: parent?.getChildList()?.remove(this)
        }
        […]
    }
The
forwardButton
is a
Node
and is created within a
toolbar
builder, so its parent should be set to that toolbar. Therefore, I’m a bit confused by the
parent?.parent
part on the left of the Elvis operator. I then tried printing the
forwardButton
(which is a
Button
), its parent (which is
null
) and its parent’s parent (which in that case obviously doesn’t exist). So, at which point in the
Workspace
does the
forwardButton
become an orphan?