dash-frontend: clock, wgui: refactoring, non-panicking casts
This commit is contained in:
@@ -32,15 +32,14 @@ fn button_click_callback(
|
||||
label: Widget,
|
||||
text: &'static str,
|
||||
) -> ButtonClickCallback {
|
||||
Box::new(move |e| {
|
||||
label.get_as_mut::<WidgetLabel>().set_text(
|
||||
&mut e.state.globals.i18n(),
|
||||
Translation::from_raw_text(text),
|
||||
);
|
||||
Box::new(move |mut e| {
|
||||
label
|
||||
.get_as_mut::<WidgetLabel>()
|
||||
.unwrap()
|
||||
.set_text(&mut e.as_common(), Translation::from_raw_text(text));
|
||||
|
||||
button.try_cast::<ComponentButton>()?.set_text(
|
||||
e.state,
|
||||
e.alterables,
|
||||
&mut e.as_common(),
|
||||
Translation::from_raw_text("this button has been clicked"),
|
||||
);
|
||||
|
||||
@@ -93,12 +92,8 @@ impl TestbedGeneric {
|
||||
|
||||
let button_click_me = state.fetch_component_as::<ComponentButton>("button_click_me")?;
|
||||
let button = button_click_me.clone();
|
||||
button_click_me.on_click(Box::new(move |e| {
|
||||
button.set_text(
|
||||
e.state,
|
||||
e.alterables,
|
||||
Translation::from_raw_text("congrats!"),
|
||||
);
|
||||
button_click_me.on_click(Box::new(move |mut e| {
|
||||
button.set_text(&mut e.as_common(), Translation::from_raw_text("congrats!"));
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
@@ -116,12 +111,10 @@ impl TestbedGeneric {
|
||||
|
||||
let cb_first = state.fetch_component_as::<ComponentCheckbox>("cb_first")?;
|
||||
let label = label_cur_option.widget.clone();
|
||||
cb_first.on_toggle(Box::new(move |e| {
|
||||
let mut widget = label.get_as_mut::<WidgetLabel>();
|
||||
widget.set_text(
|
||||
&mut e.state.globals.i18n(),
|
||||
Translation::from_raw_text(&format!("checkbox toggle: {}", e.checked)),
|
||||
);
|
||||
cb_first.on_toggle(Box::new(move |mut e| {
|
||||
let mut widget = label.get_as_mut::<WidgetLabel>().unwrap();
|
||||
let text = format!("checkbox toggle: {}", e.checked);
|
||||
widget.set_text(&mut e.as_common(), Translation::from_raw_text(&text));
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user