Context children

This commit is contained in:
2026-01-24 17:22:59 +01:00
parent abe37686d8
commit 9d55dacde2
3 changed files with 34 additions and 13 deletions
+6 -12
View File
@@ -23,20 +23,14 @@ fn main() {
}
fn app(cx: &Arc<Context>) -> View {
let mc_cx = Context::new(my_component);
cx.child(my_component, None);
cx.on_event({
let mc_cx = mc_cx.clone();
move |_, &KeyPress| {
mc_cx.emit_event(&KeyPress);
Arc::new({
let cx = cx.clone();
move |ctx| {
cx.draw_children(ctx);
}
});
mc_cx.refresh();
Arc::new(move |ctx| {
let area = ctx.allocate(0, 0, 10, 10);
ctx.draw_view(area, mc_cx.get_view());
})
}