From 26b59ea23ec176049cff8c4015f0a1e0a527cee9 Mon Sep 17 00:00:00 2001 From: Floyd Wang Date: Thu, 27 Mar 2025 11:27:38 +0800 Subject: [PATCH] story: Sync number input value when changed (#748) Closed #741 https://github.com/user-attachments/assets/ec572918-a574-4adb-a8c0-c59010dc4d5e --- crates/story/src/input_story.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/story/src/input_story.rs b/crates/story/src/input_story.rs index 902bbdb3..dea7c767 100644 --- a/crates/story/src/input_story.rs +++ b/crates/story/src/input_story.rs @@ -263,7 +263,12 @@ impl InputStory { ) { match event { NumberInputEvent::Input(input_event) => match input_event { - InputEvent::Change(text) => println!("Change: {}", text), + InputEvent::Change(text) => { + if let Ok(value) = text.parse::() { + self.number_input1_value = value; + } + println!("Change: {}", text); + } InputEvent::PressEnter => println!("PressEnter"), InputEvent::Focus => println!("Focus"), InputEvent::Blur => println!("Blur"), @@ -294,7 +299,12 @@ impl InputStory { ) { match event { NumberInputEvent::Input(input_event) => match input_event { - InputEvent::Change(text) => println!("Change: {}", text), + InputEvent::Change(text) => { + if let Ok(value) = text.parse::() { + self.number_input2_value = value; + } + println!("Change: {}", text); + } InputEvent::PressEnter => println!("PressEnter"), InputEvent::Focus => println!("Focus"), InputEvent::Blur => println!("Blur"),