aboutsummaryrefslogtreecommitdiff
path: root/src/ui/events
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-12-21 15:36:00 +0800
committercrupest <crupest@outlook.com>2021-12-21 15:36:00 +0800
commit63b39863b9d567068480f9c1d59177c92a8c6169 (patch)
tree06485cd94ca299bcc0d09fdc23fc9a73cad38eab /src/ui/events
parent061f9ad04131febcc66975fd3d95b332789da52f (diff)
downloadcru-63b39863b9d567068480f9c1d59177c92a8c6169.tar.gz
cru-63b39863b9d567068480f9c1d59177c92a8c6169.tar.bz2
cru-63b39863b9d567068480f9c1d59177c92a8c6169.zip
...
Diffstat (limited to 'src/ui/events')
-rw-r--r--src/ui/events/MouseEventArgs.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ui/events/MouseEventArgs.cpp b/src/ui/events/MouseEventArgs.cpp
index b27bb9d4..39424c65 100644
--- a/src/ui/events/MouseEventArgs.cpp
+++ b/src/ui/events/MouseEventArgs.cpp
@@ -1,5 +1,7 @@
#include "cru/ui/events/MouseEventArgs.hpp"
+#include "cru/ui/controls/Control.hpp"
+#include "cru/ui/host/WindowHost.hpp"
#include "cru/ui/render/RenderObject.hpp"
namespace cru::ui::events {
@@ -11,4 +13,16 @@ Point MouseEventArgs::GetPointToContent(
render::RenderObject* render_object) const {
return render_object->FromRootToContent(GetPoint());
}
+
+Point MouseEventArgs::GetPointOfScreen() const {
+ auto sender = GetSender();
+ if (auto control = dynamic_cast<controls::Control*>(sender)) {
+ if (auto host = control->GetWindowHost())
+ return GetPoint() + control->GetWindowHost()
+ ->GetNativeWindow()
+ ->GetClientRect()
+ .GetLeftTop();
+ }
+ return GetPoint();
+}
} // namespace cru::ui::events