Expand description
Prelude for declaring new properties and widgets.
This prelude can be imported over prelude
.
§Examples
use zng::{prelude::*, prelude_wgt::*};
/// A button with only text child.
#[widget($crate::TextButton)]
pub struct TextButton(Button);
/// Button text.
#[property(CHILD, capture, widget_impl(TextButton))]
pub fn txt(txt: impl IntoVar<Txt>) { }
impl TextButton {
fn widget_intrinsic(&mut self) {
self.widget_builder().push_build_action(|b| {
let txt = b
.capture_var::<Txt>(property_id!(Self::txt))
.unwrap_or_else(|| LocalVar(Txt::from("")).boxed());
b.set_child(Text!(txt));
});
}
}
Re-exports§
pub use crate::__prelude_wgt::*;