[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [Patch] Fix keyboard navigation (tabbing out of a textarea)
From:       bj () altern ! org
Date:       2004-07-12 12:56:12
Message-ID: 200407121502.05194.bj () altern ! org
[Download RAW message or body]

Currently, if you navigate with the keyboard using tab, navigation is severly 
blocked if you enter a textarea (you can't get out of it).

My patch implements an idea of Waldo Bastian:
By default, tab will get you out of the widget.
A new context menu entry is added to textareas: allow tabulations.

If you toggle the "allow tabulations" feature, pressing tab in the textarea 
will insert a tabulation.

This patch fixes #58247. Is it ok for you ?

["tab_exit.diff" (text/x-diff)]

Index: rendering/render_form.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.cpp,v
retrieving revision 1.264
diff -u -3 -r1.264 render_form.cpp
--- rendering/render_form.cpp	22 Jun 2004 05:46:41 -0000	1.264
+++ rendering/render_form.cpp	10 Jul 2004 18:37:43 -0000
@@ -1216,11 +1216,13 @@
     setTextFormat(QTextEdit::PlainText);
     setAutoMask(true);
     setMouseTracking(true);
-
+    
+    m_allowTab=false;
     KActionCollection *ac = new KActionCollection(this);
     m_findAction = KStdAction::find( this, SLOT( slotFind() ), ac );
     m_findNextAction = KStdAction::findNext( this, SLOT( slotFindNext() ), ac );
     m_replaceAction = KStdAction::replace( this, SLOT( slotReplace() ), ac );
+    m_allowTabAction=new KToggleAction (i18n("Allow Tabulations"),0,0,this,SLOT(slotAllowTab()),ac);
 }
 
 
@@ -1247,6 +1249,8 @@
 
     if (!isReadOnly()) {
         popup->insertSeparator();
+	m_allowTabAction->plug(popup);
+	popup->insertSeparator();
 
         m_findAction->plug(popup);
         m_findAction->setEnabled( !text().isEmpty() );
@@ -1490,6 +1494,10 @@
     m_findDlg->show();
 }
 
+void TextAreaWidget::slotAllowTab()
+{
+m_allowTab=!m_allowTab;
+}
 
 void TextAreaWidget::slotReplace()
 {
@@ -1525,6 +1533,13 @@
             }
         }
     }
+    if ( !m_allowTab && e->type() == QEvent::KeyPress ) {
+	QKeyEvent *ke = ( QKeyEvent* )e;
+	if ( ke->key() == Key_Tab ) {
+	    QApplication::sendEvent( parent(), ke );
+	    return true;
+	}
+    }
     return KTextEdit::event( e );
 }
 
Index: rendering/render_form.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_form.h,v
retrieving revision 1.110
diff -u -3 -r1.110 render_form.h
--- rendering/render_form.h	22 Jun 2004 05:46:42 -0000	1.110
+++ rendering/render_form.h	10 Jul 2004 18:37:43 -0000
@@ -53,6 +53,7 @@
 class KFind;
 class KReplace;
 class KAction;
+class KToggleAction;
 class KURLRequester;
 
 namespace DOM {
@@ -424,16 +425,19 @@
     void slotReplaceNext();
     void slotReplaceText(const QString&, int, int, int);
     void slotFindHighlight(const QString&, int, int);
+    void slotAllowTab();
 private:
     KFindDialog *m_findDlg;
     KFind *m_find;
     KReplaceDialog *m_repDlg;
     KReplace *m_replace;
+    KToggleAction *m_allowTabAction;
     KAction *m_findAction;
     KAction *m_findNextAction;
     KAction *m_replaceAction;
     int m_findIndex, m_findPara;
     int m_repIndex, m_repPara;
+    bool m_allowTab;
 };
 
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic