Allow wheel events in dialogue spin box types only when they have focus. Should resolve Feature #2585.
parent
6821cb4133
commit
9ad69d9085
@ -0,0 +1,53 @@
|
||||
#include "dialoguespinbox.hpp"
|
||||
|
||||
#include <QWheelEvent>
|
||||
|
||||
CSVWorld::DialogueSpinBox::DialogueSpinBox(QWidget *parent) : QSpinBox(parent)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSpinBox::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
setFocusPolicy(Qt::WheelFocus);
|
||||
QSpinBox::focusInEvent(event);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSpinBox::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
QSpinBox::focusOutEvent(event);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSpinBox::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (!hasFocus())
|
||||
event->ignore();
|
||||
else
|
||||
QSpinBox::wheelEvent(event);
|
||||
}
|
||||
|
||||
CSVWorld::DialogueDoubleSpinBox::DialogueDoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueDoubleSpinBox::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
setFocusPolicy(Qt::WheelFocus);
|
||||
QDoubleSpinBox::focusInEvent(event);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueDoubleSpinBox::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
QDoubleSpinBox::focusOutEvent(event);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueDoubleSpinBox::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (!hasFocus())
|
||||
event->ignore();
|
||||
else
|
||||
QDoubleSpinBox::wheelEvent(event);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
#ifndef CSV_WORLD_DIALOGUESPINBOX_H
|
||||
#define CSV_WORLD_DIALOGUESPINBOX_H
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class DialogueSpinBox : public QSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
DialogueSpinBox (QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void focusOutEvent(QFocusEvent *event);
|
||||
virtual void wheelEvent(QWheelEvent *event);
|
||||
};
|
||||
|
||||
class DialogueDoubleSpinBox : public QDoubleSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
DialogueDoubleSpinBox (QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void focusOutEvent(QFocusEvent *event);
|
||||
virtual void wheelEvent(QWheelEvent *event);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSV_WORLD_DIALOGUESPINBOX_H
|
Loading…
Reference in New Issue