From 707b67ba487e02f5deb93b017c7da49a228273c8 Mon Sep 17 00:00:00 2001 From: sshane Date: Thu, 29 Jul 2021 22:37:06 -0700 Subject: [PATCH] toggles: released -> clicked (#21786) old-commit-hash: 519e7cbe891db8e341899519e755f2b2a52823ea --- selfdrive/ui/qt/widgets/toggle.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/qt/widgets/toggle.cc b/selfdrive/ui/qt/widgets/toggle.cc index e319f80179..e909180d15 100644 --- a/selfdrive/ui/qt/widgets/toggle.cc +++ b/selfdrive/ui/qt/widgets/toggle.cc @@ -37,13 +37,13 @@ void Toggle::paintEvent(QPaintEvent *e) { } void Toggle::mouseReleaseEvent(QMouseEvent *e) { - if(!enabled) { + if (!enabled) { return; } const int left = _radius; const int right = width() - _radius; - if(_x_circle != left && _x_circle != right) { - //Don't parse touch events, while the animation is running + if ((_x_circle != left && _x_circle != right) || !this->rect().contains(e->localPos().toPoint())) { + // If mouse release isn't in rect or animation is running, don't parse touch events return; } if (e->button() & Qt::LeftButton) { @@ -80,4 +80,4 @@ void Toggle::setEnabled(bool value) { circleColor.setRgb(0x888888); green.setRgb(0x227722); } -} \ No newline at end of file +}