]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/QCommandEdit.C
fix math fonts with LyX/Mac
[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 namespace lyx {
16 namespace frontend {
17
18 QCommandEdit::QCommandEdit(QWidget * parent)
19         : QLineEdit(parent)
20 {
21         setFocusPolicy(QWidget::ClickFocus);
22 }
23
24
25 void QCommandEdit::keyPressEvent(QKeyEvent * e)
26 {
27         switch (e->key()) {
28         case Key_Escape:
29                 emit escapePressed();
30                 break;
31
32         case Key_Up:
33                 emit upPressed();
34                 break;
35
36         case Key_Down:
37                 emit downPressed();
38                 break;
39
40         default:
41                 QLineEdit::keyPressEvent(e);
42                 break;
43         }
44 }
45
46
47 bool QCommandEdit::event(QEvent * e)
48 {
49         if (e->type() != QEvent::KeyPress)
50                 return QLineEdit::event(e);
51
52         QKeyEvent * ev = (QKeyEvent *)e;
53
54         if (ev->key() != Key_Tab)
55                 return QLineEdit::event(e);
56
57         emit tabPressed();
58         return true;
59 }
60
61 } // namespace frontend
62 } // namespace lyx