OK Angus, I experimented some more and succeeded in getting it working.
Please test current CVS.

JMarc, not sure if you want this for 1.3 or not. Right-arrow is quite
annoying ...

regards
john


? a.diff
? qfont_metrics.map.C
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.473
diff -u -p -r1.473 ChangeLog
--- ChangeLog   4 Apr 2003 03:37:42 -0000       1.473
+++ ChangeLog   5 Apr 2003 21:08:56 -0000
@@ -1,3 +1,10 @@
+2003-04-05  John Levon  <[EMAIL PROTECTED]>
+
+       * QCommandBuffer.C:
+       * QCommandEdit.C:
+       * QCommandEdit.h: use tab instead of right-arrow
+       for completion
+
 2003-04-04  John Levon  <[EMAIL PROTECTED]>
 
        * panelstack.C: hide the pointless header
Index: QCommandBuffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QCommandBuffer.C,v
retrieving revision 1.14
diff -u -p -r1.14 QCommandBuffer.C
--- QCommandBuffer.C    13 Feb 2003 16:52:52 -0000      1.14
+++ QCommandBuffer.C    5 Apr 2003 21:08:57 -0000
@@ -68,11 +68,16 @@ QCommandBuffer::QCommandBuffer(QtView * 
        QPixmap qpup(toqstr(LibFileSearch("images", "up", "xpm")));
        QPixmap qpdown(toqstr(LibFileSearch("images", "down", "xpm")));
 
-       (new QToolButton(qpup, qt_("Previous command"), "", this, SLOT(up()), 
this))->show();
-       (new QToolButton(qpdown, qt_("Next command"), "", this, SLOT(down()), 
this))->show();
+       QToolButton * up = new QToolButton(qpup, qt_("Previous command"), "", this, 
SLOT(up()), this);
+       up->setFocusPolicy(NoFocus);
+       up->show();
+       QToolButton * down = new QToolButton(qpdown, qt_("Next command"), "", this, 
SLOT(down()), this);
+       down->setFocusPolicy(NoFocus);
+       down->show();
 
        edit_ = new QCommandEdit(this);
        edit_->setMinimumSize(edit_->sizeHint());
+       edit_->setFocusPolicy(ClickFocus);
        edit_->show();
        setStretchableWidget(edit_);
 
@@ -80,7 +85,7 @@ QCommandBuffer::QCommandBuffer(QtView * 
 
        connect(edit_, SIGNAL(escapePressed()), this, SLOT(cancel()));
        connect(edit_, SIGNAL(returnPressed()), this, SLOT(dispatch()));
-       connect(edit_, SIGNAL(rightPressed()), this, SLOT(complete()));
+       connect(edit_, SIGNAL(tabPressed()), this, SLOT(complete()));
        connect(edit_, SIGNAL(upPressed()), this, SLOT(up()));
        connect(edit_, SIGNAL(downPressed()), this, SLOT(down()));
 }
@@ -105,6 +110,7 @@ void QCommandBuffer::dispatch()
        controller_.dispatch(fromqstr(edit_->text()));
        view_->centralWidget()->setFocus();
        edit_->setText("");
+       edit_->clearFocus();
 }
 
 
@@ -157,9 +163,10 @@ void QCommandBuffer::complete()
 
 void QCommandBuffer::complete_selected(QString const & str)
 {
-       edit_->setText(str + ' ');
        QWidget const * widget = static_cast<QWidget const *>(sender());
        const_cast<QWidget *>(widget)->hide();
+       edit_->setText(str + ' ');
+       edit_->setFocus();
 }
 
 
Index: QCommandEdit.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QCommandEdit.C,v
retrieving revision 1.6
diff -u -p -r1.6 QCommandEdit.C
--- QCommandEdit.C      20 Oct 2002 01:48:27 -0000      1.6
+++ QCommandEdit.C      5 Apr 2003 21:08:57 -0000
@@ -12,7 +12,6 @@
 
 #include "QCommandEdit.h"
 
-
 QCommandEdit::QCommandEdit(QWidget * parent)
        : QLineEdit(parent)
 {
@@ -29,21 +28,25 @@ void QCommandEdit::keyPressEvent(QKeyEve
 
        case Key_Up:
                emit upPressed();
-                       break;
+               break;
 
        case Key_Down:
                emit downPressed();
                break;
 
-       case Key_Right:
-               if (cursorPosition() == text().length())
-                       emit rightPressed();
-               else
-                       QLineEdit::keyPressEvent(e);
-               break;
-
        default:
                QLineEdit::keyPressEvent(e);
                break;
        }
+}
+
+
+void QCommandEdit::focusOutEvent(QFocusEvent * e)
+{
+       if (e->reason() == QFocusEvent::Tab) {
+               emit tabPressed();
+               return;
+       }
+
+       QLineEdit::focusOutEvent(e);            
 }
Index: QCommandEdit.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QCommandEdit.h,v
retrieving revision 1.4
diff -u -p -r1.4 QCommandEdit.h
--- QCommandEdit.h      20 Oct 2002 01:48:27 -0000      1.4
+++ QCommandEdit.h      5 Apr 2003 21:08:57 -0000
@@ -29,9 +29,12 @@ signals:
        void downPressed();
 
        /// complete
-       void rightPressed();
+       void tabPressed();
+
 protected:
        virtual void keyPressEvent(QKeyEvent * e);
+
+       virtual void focusOutEvent(QFocusEvent * e);
 };
 
 #endif // QCOMMANDEDIT_H

Reply via email to