ESC to exit edit mode with Vim disabled

This commit is contained in:
Le Tan 2018-01-18 19:50:40 +08:00
parent 28e4818c26
commit eb25aec5b5

View File

@ -665,8 +665,9 @@ void VMdEditor::clearUnusedImages()
void VMdEditor::keyPressEvent(QKeyEvent *p_event) void VMdEditor::keyPressEvent(QKeyEvent *p_event)
{ {
int key = p_event->key();
int modifiers = p_event->modifiers(); int modifiers = p_event->modifiers();
switch (p_event->key()) { switch (key) {
case Qt::Key_Minus: case Qt::Key_Minus:
case Qt::Key_Underscore: case Qt::Key_Underscore:
// Zoom out. // Zoom out.
@ -709,6 +710,12 @@ void VMdEditor::keyPressEvent(QKeyEvent *p_event)
return; return;
} }
// Esc to exit edit mode when Vim is disabled.
if (key == Qt::Key_Escape) {
emit m_object->discardAndRead();
return;
}
VTextEdit::keyPressEvent(p_event); VTextEdit::keyPressEvent(p_event);
} }