FRQDO
12/05/2018, 5:30 AMclass 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
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?