diff --git a/UI/CWorldEditor.ui b/UI/CWorldEditor.ui index 52417c3a..1baa3f06 100644 --- a/UI/CWorldEditor.ui +++ b/UI/CWorldEditor.ui @@ -155,6 +155,12 @@ Qt::NoFocus + + QAbstractSpinBox::CorrectToNearestValue + + + false + 4 @@ -199,6 +205,12 @@ Qt::NoFocus + + QAbstractSpinBox::CorrectToNearestValue + + + false + 4 @@ -241,7 +253,13 @@ - Qt::NoFocus + Qt::ClickFocus + + + QAbstractSpinBox::CorrectToNearestValue + + + false 4 @@ -290,6 +308,9 @@ QAbstractSpinBox::CorrectToNearestValue + + false + 0.010000000000000 diff --git a/UI/WDraggableSpinBox.cpp b/UI/WDraggableSpinBox.cpp index 35666f38..130ec2ac 100644 --- a/UI/WDraggableSpinBox.cpp +++ b/UI/WDraggableSpinBox.cpp @@ -1,6 +1,7 @@ #include "WDraggableSpinBox.h" #include #include +#include #include WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent) @@ -9,6 +10,7 @@ WDraggableSpinBox::WDraggableSpinBox(QWidget *parent) : QDoubleSpinBox(parent) mDefaultValue = 0; setMinimum(-1000000.0); setMaximum(1000000.0); + lineEdit()->installEventFilter(this); } WDraggableSpinBox::~WDraggableSpinBox() @@ -80,9 +82,12 @@ void WDraggableSpinBox::wheelEvent(QWheelEvent *pEvent) else QDoubleSpinBox::wheelEvent(pEvent); } -void WDraggableSpinBox::contextMenuEvent(QContextMenuEvent *pEvent) +bool WDraggableSpinBox::eventFilter(QObject *, QEvent *pEvent) { - pEvent->ignore(); + if (pEvent->type() == QEvent::MouseButtonPress) + setFocus(); + + return false; } void WDraggableSpinBox::SetDefaultValue(double value) diff --git a/UI/WDraggableSpinBox.h b/UI/WDraggableSpinBox.h index 0fca511a..e51a8e50 100644 --- a/UI/WDraggableSpinBox.h +++ b/UI/WDraggableSpinBox.h @@ -18,7 +18,7 @@ public: void mouseReleaseEvent(QMouseEvent *pEvent); void mouseMoveEvent(QMouseEvent *pEvent); void wheelEvent(QWheelEvent *pEvent); - void contextMenuEvent(QContextMenuEvent *pEvent); + bool eventFilter(QObject *pObj, QEvent *pEvent); void SetDefaultValue(double value); }; diff --git a/UI/WIntegralSpinBox.cpp b/UI/WIntegralSpinBox.cpp index dacd2d3a..d3b91429 100644 --- a/UI/WIntegralSpinBox.cpp +++ b/UI/WIntegralSpinBox.cpp @@ -1,8 +1,10 @@ #include "WIntegralSpinBox.h" +#include #include WIntegralSpinBox::WIntegralSpinBox(QWidget *pParent) : QSpinBox(pParent) { + lineEdit()->installEventFilter(this); } WIntegralSpinBox::~WIntegralSpinBox() @@ -14,3 +16,11 @@ void WIntegralSpinBox::wheelEvent(QWheelEvent *pEvent) if (!hasFocus()) pEvent->ignore(); else QSpinBox::wheelEvent(pEvent); } + +bool WIntegralSpinBox::eventFilter(QObject *pObj, QEvent *pEvent) +{ + if (pEvent->type() == QEvent::MouseButtonPress) + setFocus(); + + return false; +} diff --git a/UI/WIntegralSpinBox.h b/UI/WIntegralSpinBox.h index 2295a6e3..09d959ae 100644 --- a/UI/WIntegralSpinBox.h +++ b/UI/WIntegralSpinBox.h @@ -11,6 +11,7 @@ public: explicit WIntegralSpinBox(QWidget *pParent); ~WIntegralSpinBox(); void wheelEvent(QWheelEvent *pEvent); + bool eventFilter(QObject *pObj, QEvent *pEvent); }; #endif // WINTEGRALSPINBOX_H diff --git a/UI/WPropertyEditor.cpp b/UI/WPropertyEditor.cpp index 8045fab8..f8353b9f 100644 --- a/UI/WPropertyEditor.cpp +++ b/UI/WPropertyEditor.cpp @@ -94,6 +94,7 @@ void WPropertyEditor::CreateEditor() pSpinBox->setRange(-128, 128); pSpinBox->setFocusPolicy(Qt::StrongFocus); + pSpinBox->setContextMenuPolicy(Qt::NoContextMenu); pSpinBox->setValue(pByteCast->Get()); mUI.EditorWidget = pSpinBox; @@ -108,6 +109,7 @@ void WPropertyEditor::CreateEditor() pSpinBox->setRange(-32768, 32767); pSpinBox->setFocusPolicy(Qt::StrongFocus); + pSpinBox->setContextMenuPolicy(Qt::NoContextMenu); pSpinBox->setValue(pShortCast->Get()); mUI.EditorWidget = pSpinBox; @@ -122,6 +124,7 @@ void WPropertyEditor::CreateEditor() pSpinBox->setRange(-2147483648, 2147483647); pSpinBox->setFocusPolicy(Qt::StrongFocus); + pSpinBox->setContextMenuPolicy(Qt::NoContextMenu); pSpinBox->setValue(pLongCast->Get()); mUI.EditorWidget = pSpinBox; @@ -136,6 +139,7 @@ void WPropertyEditor::CreateEditor() pDraggableSpinBox->setDecimals(4); pDraggableSpinBox->setFocusPolicy(Qt::StrongFocus); + pDraggableSpinBox->setContextMenuPolicy(Qt::NoContextMenu); pDraggableSpinBox->setValue(pFloatCast->Get()); mUI.EditorWidget = pDraggableSpinBox; diff --git a/UI/WVectorEditor.cpp b/UI/WVectorEditor.cpp index de6b5251..5d1c1691 100644 --- a/UI/WVectorEditor.cpp +++ b/UI/WVectorEditor.cpp @@ -13,17 +13,13 @@ WVectorEditor::WVectorEditor(QWidget *pParent) : QWidget(pParent) mpSpinBoxX->setFocusPolicy(Qt::StrongFocus); mpSpinBoxY->setFocusPolicy(Qt::StrongFocus); mpSpinBoxZ->setFocusPolicy(Qt::StrongFocus); + mpSpinBoxX->setContextMenuPolicy(Qt::NoContextMenu); + mpSpinBoxY->setContextMenuPolicy(Qt::NoContextMenu); + mpSpinBoxZ->setContextMenuPolicy(Qt::NoContextMenu); 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))); - /*mpLayout = new QHBoxLayout(this); - mpLayout->setContentsMargins(0,0,0,0); - mpLayout->addWidget(mpSpinBoxX); - mpLayout->addWidget(mpSpinBoxY); - mpLayout->addWidget(mpSpinBoxZ); - setLayout(mpLayout);*/ - mpGroupBox = new QGroupBox(this); mpFormLayout = new QFormLayout(mpGroupBox); mpFormLayout->addRow(new QLabel("X", mpGroupBox), mpSpinBoxX);