Prevented spin boxes in property editor from stealing focus on wheel scroll
This commit is contained in:
parent
7c2c1c9088
commit
8280055e21
|
@ -131,7 +131,8 @@ SOURCES += \
|
|||
Resource/CScan.cpp \
|
||||
Resource/factory/CScanLoader.cpp \
|
||||
UI/WStringPreviewPanel.cpp \
|
||||
UI/WScanPreviewPanel.cpp
|
||||
UI/WScanPreviewPanel.cpp \
|
||||
UI/WIntegralSpinBox.cpp
|
||||
|
||||
HEADERS += \
|
||||
Common/AnimUtil.h \
|
||||
|
@ -277,7 +278,8 @@ HEADERS += \
|
|||
Resource/CScan.h \
|
||||
Resource/factory/CScanLoader.h \
|
||||
UI/WStringPreviewPanel.h \
|
||||
UI/WScanPreviewPanel.h
|
||||
UI/WScanPreviewPanel.h \
|
||||
UI/WIntegralSpinBox.h
|
||||
|
||||
FORMS += \
|
||||
UI/CWorldEditorWindow.ui \
|
||||
|
|
|
@ -77,3 +77,9 @@ void WDraggableSpinBox::mouseMoveEvent(QMouseEvent*)
|
|||
mLastY = QCursor::pos().y();
|
||||
}
|
||||
}
|
||||
|
||||
void WDraggableSpinBox::wheelEvent(QWheelEvent *pEvent)
|
||||
{
|
||||
if (!hasFocus()) pEvent->ignore();
|
||||
else QDoubleSpinBox::wheelEvent(pEvent);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,10 @@ class WDraggableSpinBox : public QDoubleSpinBox
|
|||
public:
|
||||
explicit WDraggableSpinBox(QWidget *parent = 0);
|
||||
~WDraggableSpinBox();
|
||||
void mousePressEvent(QMouseEvent *Event);
|
||||
void mouseReleaseEvent(QMouseEvent *Event);
|
||||
void mouseMoveEvent(QMouseEvent *Event);
|
||||
void mousePressEvent(QMouseEvent *pEvent);
|
||||
void mouseReleaseEvent(QMouseEvent *pEvent);
|
||||
void mouseMoveEvent(QMouseEvent *pEvent);
|
||||
void wheelEvent(QWheelEvent *pEvent);
|
||||
};
|
||||
|
||||
#endif // WDRAGGABLESPINBOX_H
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#include "WIntegralSpinBox.h"
|
||||
#include <QWheelEvent>
|
||||
|
||||
WIntegralSpinBox::WIntegralSpinBox(QWidget *pParent) : QSpinBox(pParent)
|
||||
{
|
||||
}
|
||||
|
||||
WIntegralSpinBox::~WIntegralSpinBox()
|
||||
{
|
||||
}
|
||||
|
||||
void WIntegralSpinBox::wheelEvent(QWheelEvent *pEvent)
|
||||
{
|
||||
if (!hasFocus()) pEvent->ignore();
|
||||
else QSpinBox::wheelEvent(pEvent);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef WINTEGRALSPINBOX_H
|
||||
#define WINTEGRALSPINBOX_H
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
// Simple subclass to disable focus stealing on wheel event
|
||||
class WIntegralSpinBox : public QSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WIntegralSpinBox(QWidget *pParent);
|
||||
~WIntegralSpinBox();
|
||||
void wheelEvent(QWheelEvent *pEvent);
|
||||
};
|
||||
|
||||
#endif // WINTEGRALSPINBOX_H
|
|
@ -1,5 +1,6 @@
|
|||
#include "WPropertyEditor.h"
|
||||
#include "WDraggableSpinBox.h"
|
||||
#include "WIntegralSpinBox.h"
|
||||
#include "WResourceSelector.h"
|
||||
#include "WColorPicker.h"
|
||||
#include "WVectorEditor.h"
|
||||
|
@ -85,39 +86,42 @@ void WPropertyEditor::CreateEditor()
|
|||
break;
|
||||
}
|
||||
|
||||
// Byte - QSpinBox
|
||||
// Byte - WIntegralSpinBox
|
||||
case eByteProperty:
|
||||
{
|
||||
CByteProperty *pByteCast = static_cast<CByteProperty*>(mpProperty);
|
||||
QSpinBox *pSpinBox = new QSpinBox(this);
|
||||
QSpinBox *pSpinBox = new WIntegralSpinBox(this);
|
||||
|
||||
pSpinBox->setRange(-128, 128);
|
||||
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||
pSpinBox->setValue(pByteCast->Get());
|
||||
|
||||
mUI.EditorWidget = pSpinBox;
|
||||
break;
|
||||
}
|
||||
|
||||
// Short - QSpinBox
|
||||
// Short - WIntegralSpinBox
|
||||
case eShortProperty:
|
||||
{
|
||||
CShortProperty *pShortCast = static_cast<CShortProperty*>(mpProperty);
|
||||
QSpinBox *pSpinBox = new QSpinBox(this);
|
||||
QSpinBox *pSpinBox = new WIntegralSpinBox(this);
|
||||
|
||||
pSpinBox->setRange(-32768, 32767);
|
||||
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||
pSpinBox->setValue(pShortCast->Get());
|
||||
|
||||
mUI.EditorWidget = pSpinBox;
|
||||
break;
|
||||
}
|
||||
|
||||
// Long - QSpinBox
|
||||
// Long - WIntegralSpinBox
|
||||
case eLongProperty:
|
||||
{
|
||||
CLongProperty *pLongCast = static_cast<CLongProperty*>(mpProperty);
|
||||
QSpinBox *pSpinBox = new QSpinBox(this);
|
||||
QSpinBox *pSpinBox = new WIntegralSpinBox(this);
|
||||
|
||||
pSpinBox->setRange(-2147483648, 2147483647);
|
||||
pSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||
pSpinBox->setValue(pLongCast->Get());
|
||||
|
||||
mUI.EditorWidget = pSpinBox;
|
||||
|
@ -131,6 +135,7 @@ void WPropertyEditor::CreateEditor()
|
|||
WDraggableSpinBox *pDraggableSpinBox = new WDraggableSpinBox(this);
|
||||
|
||||
pDraggableSpinBox->setDecimals(4);
|
||||
pDraggableSpinBox->setFocusPolicy(Qt::StrongFocus);
|
||||
pDraggableSpinBox->setValue(pFloatCast->Get());
|
||||
|
||||
mUI.EditorWidget = pDraggableSpinBox;
|
||||
|
|
|
@ -7,6 +7,9 @@ WVectorEditor::WVectorEditor(QWidget *pParent) : QWidget(pParent)
|
|||
mpSpinBoxX = new WDraggableSpinBox(this);
|
||||
mpSpinBoxY = new WDraggableSpinBox(this);
|
||||
mpSpinBoxZ = new WDraggableSpinBox(this);
|
||||
mpSpinBoxX->setFocusPolicy(Qt::StrongFocus);
|
||||
mpSpinBoxY->setFocusPolicy(Qt::StrongFocus);
|
||||
mpSpinBoxZ->setFocusPolicy(Qt::StrongFocus);
|
||||
connect(mpSpinBoxX, SIGNAL(valueChanged(double)), this, SLOT(SetX(double)));
|
||||
connect(mpSpinBoxY, SIGNAL(valueChanged(double)), this, SLOT(SetY(double)));
|
||||
connect(mpSpinBoxZ, SIGNAL(valueChanged(double)), this, SLOT(SetZ(double)));
|
||||
|
@ -46,6 +49,9 @@ WVectorEditor::WVectorEditor(const CVector3f& Value, QWidget *pParent) : QWidget
|
|||
mpSpinBoxX->setMaximumHeight(21);
|
||||
mpSpinBoxY->setMaximumHeight(21);
|
||||
mpSpinBoxZ->setMaximumHeight(21);
|
||||
mpSpinBoxX->setFocusPolicy(Qt::StrongFocus);
|
||||
mpSpinBoxY->setFocusPolicy(Qt::StrongFocus);
|
||||
mpSpinBoxZ->setFocusPolicy(Qt::StrongFocus);
|
||||
connect(mpSpinBoxX, SIGNAL(valueChanged(double)), this, SLOT(SetX(double)));
|
||||
connect(mpSpinBoxY, SIGNAL(valueChanged(double)), this, SLOT(SetY(double)));
|
||||
connect(mpSpinBoxZ, SIGNAL(valueChanged(double)), this, SLOT(SetZ(double)));
|
||||
|
|
Loading…
Reference in New Issue