Skip to content

Commit 4317691

Browse files
committed
fix: prevent interaction with invisible legend
1 parent 873d5f9 commit 4317691

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

octproz_project/octproz/src/plotwindow1d.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ void PlotArea1D::mouseDoubleClickEvent(QMouseEvent *event) {
885885

886886
void PlotArea1D::mousePressEvent(QMouseEvent *event) {
887887
//check if this is a legend drag
888-
if (event->button() == Qt::LeftButton && this->legend->selectTest(event->pos(), false) > 0) {
888+
if (event->button() == Qt::LeftButton && this->legend->visible() && this->legend->selectTest(event->pos(), false) > 0) {
889889
draggingLegend = true;
890890
this->setCursor(Qt::ClosedHandCursor);
891891
emit legendDragging(true);
@@ -935,7 +935,7 @@ void PlotArea1D::mouseMoveEvent(QMouseEvent* event) {
935935

936936
// Calculate cursor coordinates and emit them
937937
QPointF rawCoords, processedCoords;
938-
bool isOnPlotting = this->rect().contains(event->pos()) && !(this->legend->selectTest(event->pos(), false) > 0);
938+
bool isOnPlotting = this->rect().contains(event->pos()) && !(this->legend->visible() && this->legend->selectTest(event->pos(), false) > 0);
939939

940940
if (isOnPlotting) {
941941
rawCoords = QPointF(
@@ -954,7 +954,7 @@ void PlotArea1D::mouseMoveEvent(QMouseEvent* event) {
954954
}
955955

956956
// Cursor handling
957-
if (this->legend->selectTest(event->pos(), false) > 0) {
957+
if (this->legend->visible() && this->legend->selectTest(event->pos(), false) > 0) {
958958
this->setCursor(Qt::OpenHandCursor);
959959
} else if (this->dataCursorEnabled) {
960960
this->setCursor(Qt::CrossCursor);
@@ -971,7 +971,7 @@ void PlotArea1D::mouseReleaseEvent(QMouseEvent *event) {
971971
draggingLegend = false;
972972
emit legendDragging(false);
973973
// Restore cursor
974-
if (this->legend->selectTest(event->pos(), false) > 0) {
974+
if (this->legend->visible() && this->legend->selectTest(event->pos(), false) > 0) {
975975
this->setCursor(Qt::OpenHandCursor);
976976
} else if (this->dataCursorEnabled) {
977977
this->setCursor(Qt::CrossCursor);

0 commit comments

Comments
 (0)