diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index e8a8dc0..20b893d 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -120,6 +120,19 @@ pub struct Regulator { pub set_point_spec: Signal } +impl Regulator { + pub fn try_specify_set_point(&self, spec: String) -> bool { + match spec.parse::() { + Err(_) if !spec.is_empty() => false, + set_pt => { + self.set_point.set(set_pt.ok()); + self.set_point_spec.set(spec); + true + } + } + } +} + // the velocity is expressed in uniform coordinates pub struct ElementMotion<'a> { pub key: ElementKey, diff --git a/app-proto/src/outline.rs b/app-proto/src/outline.rs index b0347f6..a48377b 100644 --- a/app-proto/src/outline.rs +++ b/app-proto/src/outline.rs @@ -50,17 +50,9 @@ fn RegulatorInput(regulator: Regulator) -> View { }, placeholder=regulator.measurement.with(|result| result.to_string()), bind:value=value, - on:change=move |_| { - let value_val = value.get_clone_untracked(); - match value_val.parse::() { - Err(_) if !value_val.is_empty() => valid.set(false), - set_pt => batch(|| { - regulator.set_point.set(set_pt.ok()); - regulator.set_point_spec.set(value_val); - valid.set(true); - }) - }; - }, + on:change=move |_| valid.set( + regulator.try_specify_set_point(value.get_clone_untracked()) + ), on:keydown={ move |event: KeyboardEvent| { match event.key().as_str() {