Fixed enter keypress for proper handling

This commit is contained in:
Jordan Sherer 2019-11-15 10:18:19 -05:00
parent ba3e521cf3
commit a1ad346cea
2 changed files with 8 additions and 2 deletions

View File

@ -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<QKeyEvent *>(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;
}

View File

@ -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()){