From a1ad346cea1625d4c00cf26e00c99e7ec2b1bc5c Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Fri, 15 Nov 2019 10:18:19 -0500 Subject: [PATCH] Fixed enter keypress for proper handling --- TransmitTextEdit.cpp | 7 ++++++- mainwindow.cpp | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/TransmitTextEdit.cpp b/TransmitTextEdit.cpp index 3b2d074..00f7f63 100644 --- a/TransmitTextEdit.cpp +++ b/TransmitTextEdit.cpp @@ -247,6 +247,7 @@ void TransmitTextEdit::on_textContentsChanged(int /*pos*/, int rem, int add){ std::copy_if(normalized.begin(), normalized.end(), std::back_inserter(result), [](QChar& c) { return c.toLatin1() != 0 && (c == 10 || (c > 31 && c < 128)); }); + if(result != text){ bool blocked = signalsBlocked(); blockSignals(true); @@ -441,7 +442,11 @@ bool TransmitTextEdit::eventFilter(QObject */*o*/, QEvent *e){ // -1. don't filter the escape key, return key, or enter key here QKeyEvent *k = static_cast(e); - if(k->key() == Qt::Key_Escape || k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter){ + if(k->key() == Qt::Key_Escape){ + return false; + } + + if(k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter){ return false; } diff --git a/mainwindow.cpp b/mainwindow.cpp index 00051cc..16f7341 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -980,7 +980,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, auto enterFilter = new EnterKeyPressEater(); connect(enterFilter, &EnterKeyPressEater::enterKeyPressed, this, [this](QObject *, QKeyEvent *, bool *pProcessed){ if(QApplication::keyboardModifiers() & Qt::ShiftModifier){ - if(pProcessed) *pProcessed = false; + // do not allow shift+enter + if(pProcessed) *pProcessed = true; return; } if(ui->extFreeTextMsgEdit->isReadOnly()){