Makes sense. It’s not a bug, it’s just something to be aware of.
tl;dr:
- for simple interaction like this, stick with
Not Hit-Testable (Self Only)for the root, notVisible - for something more complex, this can be fixed by overriding the
onMouseDownand passingUnhandled.
edit: the Not Hit-Testable (Self Only) is the desired flag in many circumstances as you generally do not want to interact with the root of the widget or the canvas the Button is sitting in; you’re interested in the Button, and that is already set to Visible.
Hope this makes sense.
The Long Version:
When you create those widgets, both buttons initially work OK because the root of the widget is set to Not Hit-Testable (Self Only) by default. You then override this setting to Visible thus forcing the widgets to consume ALL input.
When widgets are Added to Viewport, they are added in a specific Z-order (you can expand the node and amend it). The higher the Z-order, the more on top the widget is. If both Z-orders are equal (by default), the widget added last gets priority.
When you set them to Visible, the widget added last gets priority and since the root is now Visible, it hungrily consumes / blocks interaction to anything that is not itself and does not allow input to reach elements that now appear underneath according to Z-order.