Skip to content

Commit

Permalink
Rename on_create to on_build. Run fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
geom3trik authored and robbert-vdh committed Apr 19, 2022
1 parent 283a9e9 commit 334a0e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions core/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a, T> Handle<'a, T> {
self
}

pub fn on_create<F>(self, callback: F) -> Self
pub fn on_build<F>(self, callback: F) -> Self
where
F: Fn(&mut Context),
{
Expand Down Expand Up @@ -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);


}
5 changes: 3 additions & 2 deletions core/src/views/value_slider.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand Down Expand Up @@ -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);
})
Expand All @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions examples/value_slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 334a0e7

Please sign in to comment.