问题
When a parent node becomes invisible a child becomes invisible too without modifying child visible property. So how can the visibility of a child node be observed without observing all parent nodes and the hierarchy? Is there a proper event fired?
回答1:
I don't think there is a direct way to achieve what you want. There is no property to observe and no event is fired when the parent visibility changes.
You can take a look at the internal implementation of Node.parentPropertyImpl()
, which basically does what you want to avoid: it adds an InvalidationListener
to the parent's impl_treeVisibleProperty
(internal API and deprecated).
来源:https://stackoverflow.com/questions/33185073/how-to-observe-the-visibility-of-a-child-node