]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QCommandEdit.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / QCommandEdit.C
1 /**
2  * \file QCommandEdit.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #include "QCommandEdit.h"
14
15
16 QCommandEdit::QCommandEdit(QWidget * parent)
17         : QLineEdit(parent)
18 {
19         setFocusPolicy(QWidget::ClickFocus);
20 }
21
22
23 void QCommandEdit::keyPressEvent(QKeyEvent * e)
24 {
25         switch (e->key()) {
26         case Key_Escape:
27                 emit escapePressed();
28                 break;
29
30         case Key_Up:
31                 emit upPressed();
32                         break;
33
34         case Key_Down:
35                 emit downPressed();
36                 break;
37
38         case Key_Right:
39                 if (cursorPosition() == text().length())
40                         emit rightPressed();
41                 else
42                         QLineEdit::keyPressEvent(e);
43                 break;
44
45         default:
46                 QLineEdit::keyPressEvent(e);
47                 break;
48         }
49 }