Skip to content
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

Improve bevy_input_focus #16749

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Conversation

eckz
Copy link
Contributor

@eckz eckz commented Dec 10, 2024

Objective

I was curious to use the newly created bevy_input_focus, but I found some issues with it

  • It was only implementing traits for World.
  • Lack of tests
  • is_focus_within logic was incorrect.

Solution

This PR includes some improvements to the bevy_input_focus crate:

  • Add new IsFocusedHelper that doesn't require access to &World. It implements IsFocused
  • Remove IsFocused impl for DeferredWorld. Since it already implements Deref<Target=World> it was just duplication of code.
  • impl SetInputFocus for Commands. There was no way to use SetFocusCommand directly. This allows it.
  • The is_focus_within logic has been fixed to check descendants. Previously it was checking if any of the ancestors had focus which is not correct according to the documentation.
  • Added a bunch of unit tests to verify the logic of the crate.

Testing

  • Did you test these changes? If so, how? Yes, running newly added unit tests.

@IQuick143 IQuick143 added C-Code-Quality A section of code that is hard to understand or change C-Testing A change that impacts how we test Bevy or how users test their apps S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Dec 10, 2024
Copy link
Contributor

@viridia viridia left a comment

Choose a reason for hiding this comment

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

You learn something new every day :)

@viridia
Copy link
Contributor

viridia commented Dec 12, 2024

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Very nice, thanks :)

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 12, 2024
@alice-i-cecile alice-i-cecile 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 Dec 12, 2024
Merged via the queue into bevyengine:main with commit ced6159 Dec 12, 2024
36 of 37 checks passed
@eckz eckz deleted the input-focus-improvements branch December 12, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Code-Quality A section of code that is hard to understand or change C-Testing A change that impacts how we test Bevy or how users test their apps D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes 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.

4 participants