fix: some buttons triggering when releasing mouse outside (#5052)

Examples of buttons fixed with this: Usercard profile picture & split header mod mode button
This commit is contained in:
nerix
2023-12-29 14:20:07 +01:00
committed by GitHub
parent 04a46f60dc
commit d84779f127
2 changed files with 12 additions and 2 deletions
+11 -2
View File
@@ -261,17 +261,26 @@ void Button::mousePressEvent(QMouseEvent *event)
void Button::mouseReleaseEvent(QMouseEvent *event)
{
if (!this->enabled_)
{
return;
}
bool isInside = this->rect().contains(event->pos());
if (event->button() == Qt::LeftButton)
{
this->mouseDown_ = false;
if (this->rect().contains(event->pos()))
if (isInside)
{
emit leftClicked();
}
}
emit clicked(event->button());
if (isInside)
{
emit clicked(event->button());
}
}
void Button::mouseMoveEvent(QMouseEvent *event)