瀏覽代碼

Merge branch 'fixed-console-shift-home-key2'

* fixed-console-shift-home-key2:
  ctkConsole: Added direct backspace key handling
  ctkConsole: Do not allow moving before the interactive position
Jean-Christophe Fillion-Robin 10 年之前
父節點
當前提交
d6171b88d2
共有 1 個文件被更改,包括 27 次插入1 次删除
  1. 27 1
      Libs/Widgets/ctkConsole.cpp

+ 27 - 1
Libs/Widgets/ctkConsole.cpp

@@ -186,6 +186,30 @@ bool ctkConsolePrivate::isMoveLeftWithinLine(QKeyEvent* e, QTextCursor::MoveOper
     moveMode = QTextCursor::KeepAnchor;
     return true;
     }
+  else if (e == QKeySequence::MoveToStartOfBlock)
+    {
+    moveOperation = QTextCursor::StartOfLine;
+    moveMode = QTextCursor::MoveAnchor;
+    return true;
+    }
+  else if (e == QKeySequence::SelectStartOfBlock)
+    {
+    moveOperation = QTextCursor::StartOfLine;
+    moveMode = QTextCursor::KeepAnchor;
+    return true;
+    }
+  else if (e == QKeySequence::MoveToStartOfDocument)
+    {
+    moveOperation = QTextCursor::StartOfLine;
+    moveMode = QTextCursor::MoveAnchor;
+    return true;
+    }
+  else if (e == QKeySequence::SelectStartOfDocument)
+    {
+    moveOperation = QTextCursor::StartOfLine;
+    moveMode = QTextCursor::KeepAnchor;
+    return true;
+    }
   else
     {
     return false;
@@ -305,7 +329,9 @@ void ctkConsolePrivate::keyPressEvent(QKeyEvent* e)
     return;
     }
 
-  if (e == QKeySequence::Back)
+  // There seems to be no QKeySequence for backspace, therefore the key 
+  // has to be recognized directly (the same way as it is done in the parent class)
+  if (e->key() == Qt::Key_Backspace && !(e->modifiers() & ~Qt::ShiftModifier))
     {
     e->accept();
     if(text_cursor.position() > this->InteractivePosition)