]> git.lyx.org Git - features.git/commitdiff
Partial Fix for Tab key press bug. It is now properly processed but the focus is...
authorAbdelrazak Younes <younes@lyx.org>
Wed, 20 Dec 2006 21:28:05 +0000 (21:28 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Wed, 20 Dec 2006 21:28:05 +0000 (21:28 +0000)
* WorkArea.h: processKeySym() is now public

* GuiView:
  * event(): new method to intercept Tab key press.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16352 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/WorkArea.h
src/frontends/qt4/GuiView.C
src/frontends/qt4/GuiView.h

index a7ab99fc701ee59481bae5324a1d3d3489aa2a1b..01a77aed037c78ac241992ff1a31faf05ab147c9 100644 (file)
@@ -88,9 +88,10 @@ public:
        void stopBlinkingCursor();
        void startBlinkingCursor();
 
-protected:
-       ///
+       /// Process Key pressed event.
+       /// This needs to be public because it is accessed externally by GuiView.
        void processKeySym(LyXKeySymPtr key, key_modifier::state state);
+protected:
        /// cause the display of the given area of the work area
        virtual void expose(int x, int y, int w, int h) = 0;
        ///
index 863475241014b0f91d22afc29907505e9dee2d54..48565b3fb9afb6906ff61be6661a446532c36baf 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "GuiImplementation.h"
 #include "GuiWorkArea.h"
+#include "QLyXKeySym.h"
 #include "QLMenubar.h"
 #include "QLToolbar.h"
 #include "QCommandBuffer.h"
@@ -54,6 +55,7 @@
 #include <QVBoxLayout>
 
 #include <boost/bind.hpp>
+#include <boost/shared_ptr.hpp>
 
 using std::endl;
 using std::string;
@@ -608,6 +610,43 @@ void GuiView::moveEvent(QMoveEvent *)
 }
 
 
+bool GuiView::event(QEvent * e)
+{
+       // Useful debug code:
+       /*
+       switch (e->type())
+       {
+       case QEvent::WindowActivate:
+       case QEvent::ActivationChange:
+       case QEvent::WindowDeactivate:
+       case QEvent::Paint:
+       case QEvent::Enter:
+       case QEvent::Leave:
+       case QEvent::HoverEnter:
+       case QEvent::HoverLeave:
+       case QEvent::HoverMove:
+       case QEvent::StatusTip:
+               break;
+       default:
+       */
+
+       if (e->type() == QEvent::ShortcutOverride) {
+               QKeyEvent * ke = static_cast<QKeyEvent*>(e);
+               if (ke->key() == Qt::Key_Tab) {
+                       boost::shared_ptr<QLyXKeySym> sym(new QLyXKeySym);
+                       sym->set(ke);
+                       work_area_->processKeySym(sym, key_modifier::none);
+                       e->accept();
+                       centralWidget()->setFocus();
+                       return true;
+               }
+       }
+       //} for the debug switch above.
+
+       return QMainWindow::event(e);
+}
+
+
 void GuiView::show()
 {
        QMainWindow::setWindowTitle(qt_("LyX"));
index 255606be50e21297e974014e3ccd8ac1b7f91eb7..561e0b55b3634278e67484a57d77df3ea28597ff 100644 (file)
@@ -124,6 +124,9 @@ private:
         */
        virtual void setWindowTitle(lyx::docstring const & t, lyx::docstring const & it);
 
+       /// in order to catch Tab key press.
+       bool event(QEvent * e);
+
        QTimer statusbar_timer_;
 
        /// command buffer