Skip to content

Commit

Permalink
switch toggle on any point
Browse files Browse the repository at this point in the history
Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
M. Fatih Cırıt committed May 21, 2024
1 parent 009adf5 commit 97c0ce1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions common/tier4_state_rviz_plugin/src/custom_toggle_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 97c0ce1

Please sign in to comment.