From 21c00d4a0261a45821c6667b1bb9920a4882130d Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Thu, 28 Aug 2025 12:27:53 -0500 Subject: [PATCH] Pass target ID through the cutter's button handler Use the machine entity ID in the button handler prototype. Now to see about getting the FuelGauge to show the value after a button press. --- src/widgets/machines.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/widgets/machines.rs b/src/widgets/machines.rs index f3ff949..3cfc6c3 100644 --- a/src/widgets/machines.rs +++ b/src/widgets/machines.rs @@ -37,19 +37,10 @@ impl SpawnUi for CuttingMachine { )) .with_children(|cmds| { let mut button_cmds = cmds.spawn(BigRedButton::bundle("CUT")); - button_cmds.observe( - |trigger: Trigger>, - mut com: Commands, - q: Single<(Entity, &CuttingMachine)>| { - dbg!("Cut button pressed. Triggering a FuelChanged event"); - - // Feed through the target machine, once the SpawnUi trait is updated - // to require it gets here in the first place. - - let cutting_machine = q.0; - com.trigger_targets(FuelChanged, cutting_machine); - }, - ); + button_cmds.observe(move |trigger: Trigger>, mut com: Commands| { + dbg!("Cut button pressed. Triggering a FuelChanged event"); + com.trigger_targets(FuelChanged, machine_id); + }); // TODO: Attach on-press observer so this machine can do something // in response to that button being pressed });