Skip to content

Commit

Permalink
Fix miscalculation in mousePressEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
messmerd committed Aug 18, 2024
1 parent 2571547 commit ada15d3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/gui/PluginPinConnectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,21 @@ void PluginPinConnectorView::MatrixView::mousePressEvent(QMouseEvent* me)

const int buttonW = m_buttonOn.width();
const int buttonH = m_buttonOn.height();
const auto cellSize = this->cellSize();

const auto relMousePos = me->pos();
const int xIdx = relMousePos.x() / (buttonW + s_gridMargin);
const int yIdx = relMousePos.y() / (buttonH + s_gridMargin);
const int xIdx = relMousePos.x() / cellSize.width();
const int yIdx = relMousePos.y() / cellSize.height();

// Check if within margin
int relPos = relMousePos.x() - xIdx * buttonW;
int relPos = relMousePos.x() - xIdx * cellSize.width();
if (relPos >= buttonW || relPos <= 0)
{
me->ignore();
return;
}

relPos = relMousePos.y() - yIdx * buttonH;
relPos = relMousePos.y() - yIdx * cellSize.height();
if (relPos >= buttonH || relPos <= 0)
{
me->ignore();
Expand Down

0 comments on commit ada15d3

Please sign in to comment.