Inconsistent default behavior between UI picking and Interaction #16349
Labels
A-Picking
Pointing at and selecting objects of all sorts
A-UI
Graphical user interfaces, styles, layouts, and widgets
C-Bug
An unexpected or incorrect behavior
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Straightforward
Simple bug fixes and API improvements, docs, test and examples
Bevy version
0.15.0-rc.3
Additional information
Bevy currently offers two ways to interact with UI nodes:
Interaction
component (old-style)FocusPolicy
componentPickingBehavior
componentI call them "old-style" and "new-style", because
Interaction
has existed for the entire history ofbevy_ui
, whereas picking is new in 0.15. And AFAIK, the idea is to eventually deprecate and removeInteraction
and for picking to become the primary way of detecting UI Node interactions.What went wrong
Currently, the default behavior differs between the two APIs.
The default
FocusPolicy
isPass
, which allows the parent to receive interaction updates when the pointer hovers its children. This is the correct / less surprising default for UI nodes.The default
PickingBehavior
hasshould_block_lower: true
, which prevents the parent from receiving interaction updates when the pointer hovers its children.This is extremely annoying, because it leads to buggy UI when using picking, unless you override the defaults on almost every entity.
Consider the simple example of a button with some text. If the mouse is over the text, that blocks the button from receiving clicks. I have to manually override the
PickingBehavior
on the text, to get the button to work when clicking on the text.Suggested fix
should_block_lower: true
is a reasonable global default, considering that picking is used for many other cases besides UI, such as interacting with 2D and 3D entities.However, for UI Nodes, there should be a different default:
This can be done by adding
PickingBehavior
toNode
's required components list, with a non-default constructor.Open questions
Text
entities also setis_hoverable: false
(akaPickingBehavior::IGNORE
)?Text is generally expected to be non-interactable. In the use cases where it is (such as hyperlinks), the user can override the default.
Typically, users expect that UI blocks the cursor from interacting with the game world behind it. The suggested change above would fix the behavior in the context of nested UI, but the new default would also apply to the root node, causing picking to go past the UI and into the 2D/3D entities rendered behind it. This is undesirable.
It is easy enough to workaround (users can just override the default on their UI root node; certainly better than having to override the default on every other node).
This issue did not exist with the old-style
Interaction
API, because it is UI-specific, whereas picking is more general.The text was updated successfully, but these errors were encountered: