aboutsummaryrefslogtreecommitdiff
path: root/src/ui/click_detector.cpp
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-12 01:03:02 +0800
committer杨宇千 <crupest@outlook.com>2019-08-12 01:03:02 +0800
commit04367ead7027e9f0359d24681f5cc0dd916b934d (patch)
treef2a277ac9d53863c9f4efc8099450138974bdb4d /src/ui/click_detector.cpp
parent86e776eaebf7c45a269001ca7da0dfafba069d0a (diff)
downloadcru-04367ead7027e9f0359d24681f5cc0dd916b934d.tar.gz
cru-04367ead7027e9f0359d24681f5cc0dd916b934d.tar.bz2
cru-04367ead7027e9f0359d24681f5cc0dd916b934d.zip
...
Diffstat (limited to 'src/ui/click_detector.cpp')
-rw-r--r--src/ui/click_detector.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ui/click_detector.cpp b/src/ui/click_detector.cpp
index 1442b885..b335f3b5 100644
--- a/src/ui/click_detector.cpp
+++ b/src/ui/click_detector.cpp
@@ -12,8 +12,9 @@ ClickDetector::ClickDetector(Control* control) {
EventRevokerGuard(control->MouseDownEvent()->Direct()->AddHandler(
[this, control](event::MouseButtonEventArgs& args) {
if (!control->CaptureMouse()) return; // capture failed
- FromButton(args.GetMouseButton()) =
- args.GetPoint(); // save mouse down point
+ const auto button = args.GetMouseButton();
+ FromButton(button) = args.GetPoint(); // save mouse down point
+ begin_event_.Raise(button);
})));
event_rovoker_guards_.push_front(
@@ -25,8 +26,10 @@ ClickDetector::ClickDetector(Control* control) {
if (down_point.has_value()) {
event_.Raise(ClickEventArgs(control, down_point.value(),
args.GetPoint(), button));
+ end_event_.Raise(button);
down_point = std::nullopt;
}
+ control->ReleaseMouse();
})));
}
} // namespace cru::ui