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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -57,6 +57,7 @@
- Bugfix: Fixed a bug on Wayland where tooltips would spawn as separate windows instead of behaving like tooltips. (#4998, #5040)
- Bugfix: Fixes to section deletion in text input fields. (#5013)
- Bugfix: Show user text input within watch streak notices. (#5029)
- Bugfix: Fixed avatar in usercard and moderation button triggering when releasing the mouse outside their area. (#5052)
- Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978)
- Dev: Change clang-format from v14 to v16. (#4929)
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)

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)