void TextEdit::keyPressEvent(QKeyEvent *e) { if (((e->key() == Key_Enter) || (e->key() == Key_Return))){ if (!m_bCtrlMode || (e->state() & ControlButton)){ emit ctrlEnterPressed(); return; } } if (!isReadOnly()){ if ((e->state() == ShiftButton) && (e->key() == Key_Insert)){ paste(); return; } if ((e->state() == ControlButton) && (e->key() == Key_Delete)){ cut(); return; } } #if (COMPAT_QT_VERSION >= 0x030000) && (COMPAT_QT_VERSION < 0x030100) // Workaround about autoformat feature in qt 3.0.x if ((e->text()[0] == '-') || (e->text()[0] == '*')){ if (isOverwriteMode() && !hasSelectedText()) moveCursor(MoveForward, true); insert( e->text(), TRUE, FALSE ); return; } #endif // Note: We no longer translate Enter to Ctrl-Enter since we need // to know about paragraph breaks now. TextShow::keyPressEvent(e); }
void TextEdit::keyPressEvent(QKeyEvent *e) { if (((e->key() == Key_Enter) || (e->key() == Key_Return))){ if (!m_bCtrlMode || (e->state() & ControlButton)){ emit ctrlEnterPressed(); return; } } if (!isReadOnly()){ if ((e->state() == ShiftButton) && (e->key() == Key_Insert)){ paste(); return; } if ((e->state() == ControlButton) && (e->key() == Key_Delete)){ cut(); return; } } #if (QT_VERSION >= 300) && (QT_VERSION < 0x030100) // Workaround about autoformat feature in qt 3.0.x if ((e->text()[0] == '-') || (e->text()[0] == '*')){ if (isOverwriteMode() && !hasSelectedText()) moveCursor(MoveForward, true); insert( e->text(), TRUE, FALSE ); return; } #endif #if QT_VERSION >= 300 if ((e->key() == Key_Return) || (e->key() == Key_Enter)){ QKeyEvent e1(QEvent::KeyPress, e->key(), e->ascii(), e->state() | ControlButton, e->text(), e->count()); QTextEdit::keyPressEvent(&e1); return; } #endif TextShow::keyPressEvent(e); }