Browse Source

ESC to exit edit mode with Vim disabled

Le Tan 7 years ago
parent
commit
eb25aec5b5
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/vmdeditor.cpp

+ 8 - 1
src/vmdeditor.cpp

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