From 334a0e70954a5e84239b834d21fbfafb3fffd991 Mon Sep 17 00:00:00 2001 From: George Atkinson Date: Sun, 20 Mar 2022 14:39:40 +0000 Subject: [PATCH] Rename on_create to on_build. Run fmt --- core/src/handle.rs | 4 +--- core/src/views/value_slider.rs | 5 +++-- examples/value_slider.rs | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/handle.rs b/core/src/handle.rs index 4d1af1625..dba74adab 100644 --- a/core/src/handle.rs +++ b/core/src/handle.rs @@ -45,7 +45,7 @@ impl<'a, T> Handle<'a, T> { self } - pub fn on_create(self, callback: F) -> Self + pub fn on_build(self, callback: F) -> Self where F: Fn(&mut Context), { @@ -401,6 +401,4 @@ impl<'a, T> Handle<'a, T> { set_style!(border_radius_top_right, Units); set_style!(border_radius_bottom_left, Units); set_style!(border_radius_bottom_right, Units); - - } diff --git a/core/src/views/value_slider.rs b/core/src/views/value_slider.rs index 1b4588ea1..bea3b1460 100644 --- a/core/src/views/value_slider.rs +++ b/core/src/views/value_slider.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use crate::{ - Actions, Binding, Color, Context, Element, Event, Handle, Label, Lens, LensExt, Model, + Binding, Color, Context, DataContext, Element, Event, Handle, Label, Lens, LensExt, Model, Modifiers, MouseButton, Textbox, Units::*, View, WindowEvent, ZStack, }; @@ -57,7 +57,7 @@ where Binding::new(cx, VSDataInternal::edit, move |cx, edit| { if edit.get(cx) { Textbox::new(cx, lens.clone().map(|val| format!("{:.2}", val))) - .on_create(|cx| { + .on_build(|cx| { cx.emit(TextEvent::StartEdit); cx.emit(TextEvent::SelectAll); }) @@ -70,6 +70,7 @@ where .on_edit_end(|cx| { cx.emit(ValueSliderEvent::SetEdit(false)); }) + .background_color(Color::transparent()) .child_space(Stretch(1.0)) .height(Stretch(1.0)) .width(Stretch(1.0)); diff --git a/examples/value_slider.rs b/examples/value_slider.rs index 87bbbb3ff..875c98f59 100644 --- a/examples/value_slider.rs +++ b/examples/value_slider.rs @@ -22,11 +22,10 @@ impl Model for AppData { } fn main() { - let mut window_description = WindowDescription::new(); + let window_description = WindowDescription::new().with_title("Value Slider"); Application::new(window_description, |cx| { AppData { val: 0.5 }.build(cx); - ValueSlider::new(cx, AppData::val) .on_changing(|cx, val| cx.emit(AppEvent::SetValue(val))) .width(Pixels(300.0))