Skip to content

Rename some pointer events and components #19574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 10, 2025

Conversation

Jondolf
Copy link
Contributor

@Jondolf Jondolf commented Jun 10, 2025

Objective

#19366 implemented core button widgets, which included the Depressed state component.

Depressed was chosen instead of Pressed to avoid conflict with the Pointer<Pressed> event, but it is problematic and awkward in many ways:

  • Using the word "depressed" for such a high-traffic type is not great due to the obvious connection to "depressed" as in depression.
  • "Depressed" is not what I would search for if I was looking for a component like this, and I'm not aware of any other engine or UI framework using the term.
  • Depressed is not a very natural pair to the Pointer<Pressed> event.
  • It might be because I'm not a native English speaker, but I have very rarely heard someone say "a button is depressed". Seeing it, my mind initially goes from "depression??" to "oh, de-pressed, meaning released" and definitely not "is pressed", even though that is also a valid meaning for it.

A related problem is that the current Pointer<Pressed> and Pointer<Released> event names use a different verb tense than all of our other observer events such as Pointer<Click> or Pointer<DragStart>. By fixing this and renaming Pressed (and Released), we can then use Pressed instead of Depressed for the state component.

Additionally, the IsHovered and IsDirectlyHovered components added in #19366 use an inconsistent naming; the other similar components don't use an Is prefix. It also makes query filters like Has<IsHovered> and With<IsHovered> a bit more awkward.

This is partially related to Cart's picking concept proposal.

Solution

  • Rename Pointer<Pressed> to Pointer<Press>
  • Rename Pointer<Released> to Pointer<Release>
  • Rename Depressed to Pressed
  • Rename IsHovered to Hovered
  • Rename IsDirectlyHovered to DirectlyHovered

@Jondolf Jondolf added A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 10, 2025
@Jondolf Jondolf added this to the 0.17 milestone Jun 10, 2025
@Jondolf Jondolf added M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide A-Picking Pointing at and selecting objects of all sorts labels Jun 10, 2025
Copy link
Member

@cart cart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to consider removing the generic Pointer<T> entirely in favor of PointerPress, PointerRelease, etc (freeing up Press and Release in the global namespace and flattening out the events, making them easier to consume). And there are a few other renames I'd like to do (as defined in my proposal). But I'm on board for these changes!

@Jondolf Jondolf added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 10, 2025
@cart cart added this pull request to the merge queue Jun 10, 2025
Merged via the queue into bevyengine:main with commit 33c6f45 Jun 10, 2025
37 of 38 checks passed
@Jondolf Jondolf deleted the core-widget-state-renames branch June 10, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Picking Pointing at and selecting objects of all sorts A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants