mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
89394bcd0f
Previously, only the suggestions starting with the current input were shown. Contains the following minor improvements: - Add space to indicate when only one suggestion is found - Select first item in suggestion-list in order to make selecting with arrow keys more intuitive - Fix selection with Shift+Up/Down in text-field Fix for bug #12572.
77 lines
1.2 KiB
C++
77 lines
1.2 KiB
C++
/**
|
|
* \file GuiCommandEdit.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author John Levon
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "GuiCommandEdit.h"
|
|
|
|
#include <QKeyEvent>
|
|
#include <QEvent>
|
|
|
|
#undef KeyPress
|
|
|
|
namespace lyx {
|
|
namespace frontend {
|
|
|
|
GuiCommandEdit::GuiCommandEdit(QWidget * parent)
|
|
: QLineEdit(parent)
|
|
{
|
|
setFocusPolicy(Qt::ClickFocus);
|
|
}
|
|
|
|
|
|
void GuiCommandEdit::keyPressEvent(QKeyEvent * e)
|
|
{
|
|
if (e->modifiers() == Qt::NoModifier) {
|
|
switch (e->key()) {
|
|
case Qt::Key_Escape:
|
|
// emit signal
|
|
escapePressed();
|
|
return;
|
|
|
|
case Qt::Key_Up:
|
|
// emit signal
|
|
upPressed();
|
|
return;
|
|
|
|
case Qt::Key_Down:
|
|
// emit signal
|
|
downPressed();
|
|
return;
|
|
|
|
default:
|
|
// do nothing
|
|
break;
|
|
}
|
|
}
|
|
QLineEdit::keyPressEvent(e);
|
|
}
|
|
|
|
|
|
bool GuiCommandEdit::event(QEvent * e)
|
|
{
|
|
if (e->type() != QEvent::KeyPress)
|
|
return QLineEdit::event(e);
|
|
|
|
QKeyEvent * ev = (QKeyEvent *)e;
|
|
|
|
if (ev->key() != Qt::Key_Tab)
|
|
return QLineEdit::event(e);
|
|
|
|
// emit signal
|
|
tabPressed();
|
|
return true;
|
|
}
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|
|
|
|
#include "moc_GuiCommandEdit.cpp"
|