From 97c0ce1610553519f58abbca09130df3ca343780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 21 May 2024 15:08:55 +0300 Subject: [PATCH] switch toggle on any point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp b/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp index de3d81708590d..3b58ded626439 100644 --- a/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp +++ b/common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp @@ -73,10 +73,7 @@ void CustomToggleSwitch::paintEvent(QPaintEvent *) void CustomToggleSwitch::mouseReleaseEvent(QMouseEvent * event) { if (event->button() == Qt::LeftButton) { - int middleX = rect().center().x(); // Calculate the middle of the switch - bool newState = event->pos().x() >= middleX; // Determine new state based on click position - - setCheckedState(newState); + setCheckedState(!isChecked()); } QCheckBox::mouseReleaseEvent(event); }