[Rust] AwmWindow sets an element's parent when it's added to the hierarchy
@@ -83,9 +83,13 @@ impl AwmWindow {
}
}
- pub fn add_component(&self, elem: Rc<dyn UIElement>) {
+ pub fn add_component(self: Rc<Self>, elem: Rc<dyn UIElement>) {
// Ensure the component has a frame by running its sizer
elem.handle_superview_resize(*self.current_size.borrow());
+
+ // Set up a link to the parent
+ elem.set_parent(Rc::downgrade(&(Rc::clone(&self) as _)));
+
self.ui_elements.borrow_mut().push(elem);
}
