Only close texture goto when focus is lost

* Previously this closed as soon as the mouse left the bounds.
This commit is contained in:
baldurk
2025-03-28 11:20:01 +00:00
parent 00381637a7
commit e4af8bcf39
4 changed files with 29 additions and 0 deletions
@@ -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);
}
@@ -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;
};
+19
View File
@@ -79,6 +79,9 @@ TextureGoto::TextureGoto(QWidget *parent, std::function<void(QPoint)> 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());
+2
View File
@@ -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<void(QPoint)> m_Callback;