diff options
author | 杨宇千 <crupest@outlook.com> | 2019-09-13 23:38:16 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-09-13 23:38:16 +0800 |
commit | 401ca68f7d9d62d195c558edfeda4ece985805e1 (patch) | |
tree | c31d89661825a08441fff2673b065d42c423c95c /src/ui/window.cpp | |
parent | e3423168a298139051e6bc8b9bacf8b7d594c94e (diff) | |
download | cru-401ca68f7d9d62d195c558edfeda4ece985805e1.tar.gz cru-401ca68f7d9d62d195c558edfeda4ece985805e1.tar.bz2 cru-401ca68f7d9d62d195c558edfeda4ece985805e1.zip |
...
Diffstat (limited to 'src/ui/window.cpp')
-rw-r--r-- | src/ui/window.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/ui/window.cpp b/src/ui/window.cpp index 834b924c..af95c3c6 100644 --- a/src/ui/window.cpp +++ b/src/ui/window.cpp @@ -232,15 +232,19 @@ void Window::OnNativeMouseEnterLeave(bool enter) { void Window::OnNativeMouseMove(const Point& point) { // Find the first control that hit test succeed. - const auto new_control_mouse_hover = HitTest(point); - const auto old_control_mouse_hover = mouse_hover_control_; - mouse_hover_control_ = new_control_mouse_hover; + const auto new_mouse_hover_control = HitTest(point); + const auto old_mouse_hover_control = mouse_hover_control_; + mouse_hover_control_ = new_mouse_hover_control; if (mouse_captured_control_) { - DispatchMouseHoverControlChangeEvent( - mouse_captured_control_, new_control_mouse_hover, point, false, true); - DispatchMouseHoverControlChangeEvent( - old_control_mouse_hover, mouse_captured_control_, point, true, false); + const auto n = FindLowestCommonAncestor(new_mouse_hover_control, mouse_captured_control_); + const auto o = FindLowestCommonAncestor(old_mouse_hover_control, mouse_captured_control_); + bool a = IsAncestor(o, n); + if (a) { + DispatchEvent(event_names::MouseLeave, o, &Control::MouseLeaveEvent, n); + } else { + DispatchEvent(event_names::MouseEnter, n, &Control::MouseEnterEvent, o, point); + } DispatchEvent(event_names::MouseMove, mouse_captured_control_, &Control::MouseMoveEvent, nullptr, point); UpdateCursor(); @@ -248,8 +252,8 @@ void Window::OnNativeMouseMove(const Point& point) { } DispatchMouseHoverControlChangeEvent( - old_control_mouse_hover, new_control_mouse_hover, point, false, false); - DispatchEvent(event_names::MouseMove, new_control_mouse_hover, + old_mouse_hover_control, new_mouse_hover_control, point, false, false); + DispatchEvent(event_names::MouseMove, new_mouse_hover_control, &Control::MouseMoveEvent, nullptr, point); UpdateCursor(); } |