From 42f9f6c0bce5b3bea05edf4e371539fe21ea1c5d Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 13 Sep 2018 23:11:52 +0800 Subject: ... --- CruUI/ui/control.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'CruUI/ui/control.cpp') diff --git a/CruUI/ui/control.cpp b/CruUI/ui/control.cpp index 41693ed8..4d9f0593 100644 --- a/CruUI/ui/control.cpp +++ b/CruUI/ui/control.cpp @@ -28,6 +28,11 @@ namespace cru { } + Control::Control(WindowConstructorTag, Window* window) : Control(true) + { + window_ = window; + } + Control::~Control() { ForeachChild([](auto control) @@ -275,7 +280,7 @@ namespace cru { void Control::OnAddChild(Control* child) { - if (auto window = dynamic_cast(GetAncestor())) + if (auto window = GetWindow()) { child->TraverseDescendants([window](Control* control) { control->OnAttachToWindow(window); @@ -287,7 +292,7 @@ namespace cru { void Control::OnRemoveChild(Control* child) { - if (auto window = dynamic_cast(GetAncestor())) + if (auto window = GetWindow()) { child->TraverseDescendants([window](Control* control) { control->OnDetachToWindow(window); -- cgit v1.2.3