diff --git a/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.cpp b/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.cpp index 62d1c5eb7..5dd3ad9b6 100644 --- a/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.cpp +++ b/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.cpp @@ -37,3 +37,9 @@ void RDDoubleSpinBox::keyPressEvent(QKeyEvent *e) emit keyPress(e); QDoubleSpinBox::keyPressEvent(e); } + +void RDDoubleSpinBox::focusOutEvent(QFocusEvent *e) +{ + emit focusOut(e); + QDoubleSpinBox::focusOutEvent(e); +} diff --git a/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.h b/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.h index e5eb749a3..65cdfacc2 100644 --- a/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.h +++ b/qrenderdoc/Widgets/Extended/RDDoubleSpinBox.h @@ -36,7 +36,9 @@ public: signals: void keyPress(QKeyEvent *e); + void focusOut(QFocusEvent *e); private: void keyPressEvent(QKeyEvent *e) override; + void focusOutEvent(QFocusEvent *e) override; }; diff --git a/qrenderdoc/Widgets/TextureGoto.cpp b/qrenderdoc/Widgets/TextureGoto.cpp index a26fcbfc7..7c4a615db 100644 --- a/qrenderdoc/Widgets/TextureGoto.cpp +++ b/qrenderdoc/Widgets/TextureGoto.cpp @@ -79,6 +79,9 @@ TextureGoto::TextureGoto(QWidget *parent, std::function callback) QObject::connect(m_X, &RDDoubleSpinBox::keyPress, this, &TextureGoto::location_keyPress); QObject::connect(m_Y, &RDDoubleSpinBox::keyPress, this, &TextureGoto::location_keyPress); + QObject::connect(m_X, &RDDoubleSpinBox::focusOut, this, &TextureGoto::focusOut); + QObject::connect(m_Y, &RDDoubleSpinBox::focusOut, this, &TextureGoto::focusOut); + gridLayout->addWidget(m_Y, 1, 1, 1, 1); setTabOrder(m_X, m_Y); @@ -108,11 +111,27 @@ void TextureGoto::show(QWidget *showParent, QPoint p) void TextureGoto::leaveEvent(QEvent *event) { +} + +void TextureGoto::focusOutEvent(QFocusEvent *event) +{ + focusOut(event); +} + +void TextureGoto::focusOut(QFocusEvent *event) +{ + if(QApplication::focusWidget() == m_X || QApplication::focusWidget() == m_Y || isHidden()) + return; + QDialog::hide(); } void TextureGoto::location_keyPress(QKeyEvent *event) { + if(event->key() == Qt::Key_Escape) + { + QDialog::hide(); + } if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { m_Callback(point()); diff --git a/qrenderdoc/Widgets/TextureGoto.h b/qrenderdoc/Widgets/TextureGoto.h index 3be1be077..4b8a13c50 100644 --- a/qrenderdoc/Widgets/TextureGoto.h +++ b/qrenderdoc/Widgets/TextureGoto.h @@ -42,9 +42,11 @@ signals: public slots: void location_keyPress(QKeyEvent *); + void focusOut(QFocusEvent *event); private: void leaveEvent(QEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; RDDoubleSpinBox *m_X, *m_Y; std::function m_Callback;