From 7a564d98db0b7c7be5b3bfac955cb88998a472ac Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 29 Mar 2022 12:24:06 +0800 Subject: ... --- src/ui/host/WindowHost.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/ui/host/WindowHost.cpp') diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp index f4a9a928..737a7594 100644 --- a/src/ui/host/WindowHost.cpp +++ b/src/ui/host/WindowHost.cpp @@ -7,6 +7,7 @@ #include "cru/platform/gui/InputMethod.h" #include "cru/platform/gui/UiApplication.h" #include "cru/platform/gui/Window.h" +#include "cru/ui/Base.h" #include "cru/ui/DebugFlags.h" #include "cru/ui/host/LayoutPaintCycler.h" #include "cru/ui/render/MeasureRequirement.h" @@ -105,6 +106,15 @@ inline void BindNativeEvent( } } // namespace +int WindowHost::event_handling_depth_ = 0; + +void WindowHost::EnterEventHandling() { event_handling_depth_++; } + +void WindowHost::LeaveEventHandling() { + Expects(event_handling_depth_ > 0); + event_handling_depth_--; +} + WindowHost::WindowHost(controls::Control* root_control) : root_control_(root_control), focus_control_(root_control) { root_render_object_ = root_control->GetRenderObject(); @@ -438,4 +448,16 @@ void WindowHost::SetOverrideCursor( override_cursor_ = cursor; UpdateCursor(); } + +void WindowHost::OnControlDetach(controls::Control* control) { + if (GetFocusControl() == control) { + SetFocusControl(nullptr); + } + if (GetMouseCaptureControl() == control) { + CaptureMouseFor(nullptr); + } + if (GetMouseHoverControl() == control) { + mouse_hover_control_ = HitTest(GetNativeWindow()->GetMousePosition()); + } +} } // namespace cru::ui::host -- cgit v1.2.3