From 04367ead7027e9f0359d24681f5cc0dd916b934d Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Mon, 12 Aug 2019 01:03:02 +0800 Subject: ... --- src/ui/control.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/ui/control.cpp') diff --git a/src/ui/control.cpp b/src/ui/control.cpp index d529b687..7bd33d84 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -54,6 +54,7 @@ void Control::_TraverseDescendants( predicate(control); for (auto c : control->GetChildren()) _TraverseDescendants(c, predicate); } + bool Control::RequestFocus() { auto window = GetWindow(); if (window == nullptr) return false; @@ -68,15 +69,21 @@ bool Control::HasFocus() { return window->GetFocusControl() == this; } -void Control::OnParentChanged(Control* old_parent, Control* new_parent) {} +bool Control::CaptureMouse() { + return GetWindow()->CaptureMouseFor(this); +} -void Control::OnAttachToWindow(Window* window) {} +bool Control::ReleaseMouse() { + return GetWindow()->CaptureMouseFor(nullptr); +} -void Control::OnDetachToWindow(Window* window) {} +bool Control::IsMouseCaptured() { + return GetWindow()->GetMouseCaptureControl() == this; +} -void Control::OnMouseClickBegin(platform::native::MouseButton button) {} +void Control::OnParentChanged(Control* old_parent, Control* new_parent) {} -void Control::OnMouseClickEnd(platform::native::MouseButton button) {} +void Control::OnAttachToWindow(Window* window) {} -void Control::OnMouseClickCancel(platform::native::MouseButton button) {} +void Control::OnDetachToWindow(Window* window) {} } // namespace cru::ui -- cgit v1.2.3