Sketcher: Make TAB lock the label if user has typed previously

This commit is contained in:
tetektoza
2025-06-21 13:48:12 +02:00
parent 9912c029dc
commit 7515c70b67

View File

@@ -215,9 +215,15 @@ bool EditableDatumLabel::eventFilter(QObject* watched, QEvent* event)
{
if (event->type() == QEvent::KeyPress) {
auto* keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Tab) {
if (auto* spinBox = qobject_cast<QAbstractSpinBox*>(watched)) {
// if tab has been pressed and user did not type anything previously,
// then just cycle but don't lock anything, otherwise we lock the label
if (keyEvent->key() == Qt::Key_Tab && !this->isSet) {
return false;
}
// for ctrl + enter we accept values as they are
if (keyEvent->modifiers() & Qt::ControlModifier) {
Q_EMIT this->finishEditingOnAllOVPs();