* escape hides the completion

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23258 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2008-02-26 19:19:34 +00:00
parent 7f39b79d55
commit eb86fb460e
3 changed files with 45 additions and 2 deletions

View File

@ -498,6 +498,32 @@ void GuiCompleter::showInline()
}
void GuiCompleter::hidePopup()
{
Cursor cur = gui_->bufferView().cursor();
cur.updateFlags(Update::None);
hidePopup(cur);
// redraw if needed
if (cur.disp_.update())
gui_->bufferView().processUpdateFlags(cur.disp_.update());
}
void GuiCompleter::hideInline()
{
Cursor cur = gui_->bufferView().cursor();
cur.updateFlags(Update::None);
hideInline(cur);
// redraw if needed
if (cur.disp_.update())
gui_->bufferView().processUpdateFlags(cur.disp_.update());
}
void GuiCompleter::activate()
{
if (!popupVisible() && !inlineVisible())

View File

@ -74,6 +74,11 @@ public Q_SLOTS:
/// Show the inline completion.
void showInline();
/// Hide the popup.
void hidePopup();
/// Hide the inline completion.
void hideInline();
private Q_SLOTS:
///
void popupActivated(const QString & completion);

View File

@ -743,13 +743,25 @@ void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
}
}
// intercept tab for inline completion
// intercept keys for the completion
if (ev->key() == Qt::Key_Tab) {
completer_.tab();
ev->accept();
return;
}
if (completer_.popupVisible() && ev->key() == Qt::Key_Escape) {
completer_.hidePopup();
ev->accept();
return;
}
if (completer_.inlineVisible() && ev->key() == Qt::Key_Escape) {
completer_.hideInline();
ev->accept();
return;
}
// do nothing if there are other events
// (the auto repeated events come too fast)
// \todo FIXME: remove hard coded Qt keys, process the key binding