style.display and events

When you set style.display = DisplayStyle.None on your root VisualElement, this propagates down through the tree, right?

What happens to callbacks you have set on elements in the tree, like ClickEvent, for instance. Do they get disabled too? I have some weird behaviors going on, so trying to understand this stuff better.

Surely some readers know the answers, please?

It’s a bit tricky. If you are doing things by code, you have to make sure the children are set to style.display = StyleKeyword.Null if you want them to respect their parent up the chain.

If a child has style.display = DisplayStyle.None and a parent has a different setting the child will potentially override the parent for its own style and its progeny.

So just make sure you are always setting things you want visible to StyleKeyword.Null (rather than DisplayStyle.Flex which can override parental settings unless this is intended) and this resets cooperative hierarchy behavior.

Things that are DisplayStyle.None or Visibility.Hidden should not catch clicks if they are truly in those states.

If you are also using IL2CPP there is a major bug to be aware of in this if you are trying to Debug behaviors or control behavior from the states:

If you are not sure if your element has the correct visibility you can try to debug it on an event or update loop via reading the output of visualElement.visible which will return true if it is visible in any way (ie. not hidden by style.display or style.visibility). Or you can go Window > UI Toolkit > Debugger and work through and edit the hierarchy until you find the problem.

Thanks very much for your detailed reply @mikejm ! It gives me plenty to go on. Thanks again!