Skip to content

Commit 97c0ce1

Browse files
author
M. Fatih Cırıt
committed
switch toggle on any point
Signed-off-by: M. Fatih Cırıt <mfc@leodrive.ai>
1 parent 009adf5 commit 97c0ce1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ void CustomToggleSwitch::paintEvent(QPaintEvent *)
7373
void CustomToggleSwitch::mouseReleaseEvent(QMouseEvent * event)
7474
{
7575
if (event->button() == Qt::LeftButton) {
76-
int middleX = rect().center().x(); // Calculate the middle of the switch
77-
bool newState = event->pos().x() >= middleX; // Determine new state based on click position
78-
79-
setCheckedState(newState);
76+
setCheckedState(!isChecked());
8077
}
8178
QCheckBox::mouseReleaseEvent(event);
8279
}

0 commit comments

Comments
 (0)