From e55f0e74ea86215e4e588c40b5183802616948d3 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Tue, 17 Dec 2024 16:16:39 -0800 Subject: [PATCH] Document input focus helper methods (#16875) # Objective I am suspicious of the command / world helpers for input focus, since they just provide a trivial helper for setting a resource value. ## Solution Document that there's nothing magic about them. These can live another day, but I would also remove them completely if y'all convince me it's the right choice. --- crates/bevy_input_focus/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/bevy_input_focus/src/lib.rs b/crates/bevy_input_focus/src/lib.rs index cb2e24bfa8..400f36986f 100644 --- a/crates/bevy_input_focus/src/lib.rs +++ b/crates/bevy_input_focus/src/lib.rs @@ -46,10 +46,17 @@ pub struct InputFocus(pub Option); pub struct InputFocusVisible(pub bool); /// Helper functions for [`World`], [`DeferredWorld`] and [`Commands`] to set and clear input focus. +/// +/// These methods are equivalent to modifying the [`InputFocus`] resource directly, +/// but only take effect when commands are applied. pub trait SetInputFocus { /// Set input focus to the given entity. + /// + /// This is equivalent to setting the [`InputFocus`]'s entity to `Some(entity)`. fn set_input_focus(&mut self, entity: Entity); /// Clear input focus. + /// + /// This is equivalent to setting the [`InputFocus`]'s entity to `None`. fn clear_input_focus(&mut self); } @@ -82,6 +89,8 @@ impl<'w> SetInputFocus for DeferredWorld<'w> { } /// Command to set input focus to the given entity. +/// +/// Generated via the methods in [`SetInputFocus`]. pub struct SetFocusCommand(Option); impl Command for SetFocusCommand {