Skip to content

Commit ced6159

Browse files
authored
Improve bevy_input_focus (#16749)
# 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. ---
1 parent b2d3371 commit ced6159

File tree

2 files changed

+244
-56
lines changed

2 files changed

+244
-56
lines changed

crates/bevy_input_focus/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ description = "Keyboard focus management"
66
homepage = "https://bevyengine.org"
77
repository = "https://github.com/bevyengine/bevy"
88
license = "MIT OR Apache-2.0"
9-
keywords = ["bevy", "color"]
9+
keywords = ["bevy"]
1010
rust-version = "1.76.0"
1111

1212
[dependencies]
1313
bevy_app = { path = "../bevy_app", version = "0.15.0-dev", default-features = false }
1414
bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev", default-features = false }
1515
bevy_input = { path = "../bevy_input", version = "0.15.0-dev", default-features = false }
1616
bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.15.0-dev", default-features = false }
17-
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev", default-features = false }
1817
bevy_window = { path = "../bevy_window", version = "0.15.0-dev", default-features = false }
1918

19+
[dev-dependencies]
20+
smol_str = "0.2"
21+
2022
[lints]
2123
workspace = true
2224

0 commit comments

Comments
 (0)