BambooTracker/gui/wheel_spin_box.cpp
raw| 1 | #include "wheel_spin_box.hpp" |
| 2 | |
| 3 | #include <QLineEdit> |
| 4 | |
| 5 | WheelSpinBox::WheelSpinBox(QWidget * parent) : |
| 6 | QSpinBox(parent) |
| 7 | { |
| 8 | // Prevent mouse scrolling from focusing the QSpinBox. |
| 9 | QSpinBox::setFocusPolicy(Qt::StrongFocus); |
| 10 | } |
| 11 | |
| 12 | void WheelSpinBox::stepBy(int steps) |
| 13 | { |
| 14 | QSpinBox::stepBy(steps); |
| 15 | |
| 16 | // Prevent mouse scrolling from permanently selecting the QSpinBox. |
| 17 | if (!QSpinBox::hasFocus()) { |
| 18 | QSpinBox::lineEdit()->deselect(); |
| 19 | } |
| 20 | } |