]> git.lyx.org Git - features.git/commitdiff
* escape hides the completion
authorStefan Schimanski <sts@lyx.org>
Tue, 26 Feb 2008 19:19:34 +0000 (19:19 +0000)
committerStefan Schimanski <sts@lyx.org>
Tue, 26 Feb 2008 19:19:34 +0000 (19:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23258 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiCompleter.cpp
src/frontends/qt4/GuiCompleter.h
src/frontends/qt4/GuiWorkArea.cpp

index 95bbfbe0418a115aea018635d0aa397ce1c97ff6..df061cb9401b1dbfb7a9d43231c1b828610c09f0 100644 (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())
index 250b3cc3ceee744293e1b4d0cdd091932d73646d..89028c75e431fc2cd3f9180a39afe8a8e028f9fa 100644 (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);
index a99938bbdf0f7ca35d78b0b54608ffb165cefca4..50dad561e77318824d009d503667e20c594df0f7 100644 (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