Skip to content

Commit

Permalink
Fix NoScrollComboBox and NoScrollSpinBox stopping parent's scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinRichards committed Oct 10, 2024
1 parent e38e05e commit caeaeac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
- Fix stitched map images sometimes rendering garbage
- Fix the `Reset` button on `Export Map Timelapse Image` not resetting the Timelapse settings.
- Stop sliders in the Palette Editor from creating a bunch of edit history when used.
- Fix scrolling on some containers locking up when the mouse stops over a spin box or combo box.

## [5.4.1] - 2024-03-21
### Fixed
Expand Down
6 changes: 5 additions & 1 deletion src/ui/noscrollcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <QCompleter>
#include <QLineEdit>
#include <QWheelEvent>

NoScrollComboBox::NoScrollComboBox(QWidget *parent)
: QComboBox(parent)
Expand Down Expand Up @@ -39,8 +40,11 @@ void NoScrollComboBox::wheelEvent(QWheelEvent *event)
{
// By default NoScrollComboBoxes will allow scrolling to modify its contents only when it explicitly has focus.
// If focusedScrollingEnabled is false it won't allow scrolling even with focus.
if (this->focusedScrollingEnabled && hasFocus())
if (this->focusedScrollingEnabled && hasFocus()) {
QComboBox::wheelEvent(event);
} else {
event->ignore();
}
}

void NoScrollComboBox::setFocusedScrollingEnabled(bool enabled)
Expand Down
6 changes: 5 additions & 1 deletion src/ui/noscrollspinbox.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "noscrollspinbox.h"
#include <QWheelEvent>

unsigned actionId = 0xffff;

Expand All @@ -12,8 +13,11 @@ NoScrollSpinBox::NoScrollSpinBox(QWidget *parent)
void NoScrollSpinBox::wheelEvent(QWheelEvent *event)
{
// Only allow scrolling to modify contents when it explicitly has focus.
if (hasFocus())
if (hasFocus()) {
QSpinBox::wheelEvent(event);
} else {
event->ignore();
}
}

void NoScrollSpinBox::focusOutEvent(QFocusEvent *event) {
Expand Down

0 comments on commit caeaeac

Please sign in to comment.