From: Stefan Schimanski Date: Tue, 26 Feb 2008 19:19:34 +0000 (+0000) Subject: * escape hides the completion X-Git-Tag: 1.6.10~6065 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=eb86fb460e9ab71a2d677bf5ed0d238624d9a4f6;p=features.git * escape hides the completion git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23258 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp index 95bbfbe041..df061cb940 100644 --- a/src/frontends/qt4/GuiCompleter.cpp +++ b/src/frontends/qt4/GuiCompleter.cpp @@ -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()) diff --git a/src/frontends/qt4/GuiCompleter.h b/src/frontends/qt4/GuiCompleter.h index 250b3cc3ce..89028c75e4 100644 --- a/src/frontends/qt4/GuiCompleter.h +++ b/src/frontends/qt4/GuiCompleter.h @@ -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); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index a99938bbdf..50dad561e7 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -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