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

List:       kfm-devel
Subject:    Re: [Patch] Fix keyboard navigation (tabbing out of a textarea)
From:       bj () altern ! org
Date:       2004-07-13 9:48:34
Message-ID: 200407131156.25483.bj () altern ! org
[Download RAW message or body]

On Monday 12 July 2004 23.54, Dawit A. wrote:

> > This patch fixes #58247. Is it ok for you ?
>
> I cannot comment on the correctness of the patch, however where you are
> attempting to fix this is incorrect IMHO. This issue does not only affect
> khtml, but any other dialog/widget that uses a text edit. IMHO, such a fix
> belongs in [Q/K]TextEdit so that it can be used everywhere consistently.
> What the patch does makes things only more inconsistent...

I think it would be good to have this bug fixed in KDE 3.3. Here is a patch 
that fixes the issue at the ktextedit level.

I added a slot tabulationsEnabled(), which should make it possible (with some 
work) for Konqueror to remember the value and always use the last one instead 
of always false at startup...

comments ?

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

Index: kdeui/ktextedit.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktextedit.cpp,v
retrieving revision 1.20
diff -u -3 -r1.20 ktextedit.cpp
--- kdeui/ktextedit.cpp	28 Jun 2004 16:53:14 -0000	1.20
+++ kdeui/ktextedit.cpp	13 Jul 2004 09:46:16 -0000
@@ -38,7 +38,8 @@
         : customPalette( false ),
           checkSpellingEnabled( false ),
           highlighter( 0 ),
-          spell( 0 )
+          spell( 0 ),
+	  allowTabulations(true)
     {}
     ~KTextEditPrivate() {
         delete highlighter;
@@ -49,6 +50,7 @@
     bool checkSpellingEnabled;
     KDictSpellingHighlighter *highlighter;
     KSpell *spell;
+    bool allowTabulations;
 };
 
 KTextEdit::KTextEdit( const QString& text, const QString& context,
@@ -179,7 +181,10 @@
         e->ignore();
         return;
     }
-
+    
+    if ( !d->allowTabulations && e->key() == Key_Tab)
+	QApplication::sendEvent( parent(), e );
+    else
     QTextEdit::keyPressEvent( e );
 }
 
@@ -197,6 +202,21 @@
     removeSelectedText();
 }
 
+void KTextEdit::slotAllowTab()
+{
+d->allowTabulations=!d->allowTabulations;
+}
+
+void KTextEdit::setTabulationsEnabled(bool check)
+{
+d->allowTabulations=check;
+}
+
+bool KTextEdit::tabulationsEnabled() const
+{
+return d->allowTabulations;
+}
+
 QPopupMenu *KTextEdit::createPopupMenu( const QPoint &pos )
 {
     enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll };
@@ -213,12 +233,9 @@
       menu->changeItem( id - IdCopy, SmallIconSet("editcopy"), menu->text( id - IdCopy) );
       menu->changeItem( id - IdPaste, SmallIconSet("editpaste"), menu->text( id - IdPaste) );
       menu->changeItem( id - IdClear, SmallIconSet("editclear"), menu->text( id - IdClear) );
-    }
-
-    if ( !isReadOnly() ) {
 
         menu->insertSeparator();
-        int id = menu->insertItem( SmallIconSet( "spellcheck" ), i18n( "Check Spelling..." ),
+        id = menu->insertItem( SmallIconSet( "spellcheck" ), i18n( "Check Spelling..." ),
                                    this, SLOT( checkSpelling() ) );
 
         if( text().isEmpty() )
@@ -227,6 +244,9 @@
         id = menu->insertItem( i18n( "Auto Spell Check" ),
                                this, SLOT( toggleAutoSpellCheck() ) );
         menu->setItemChecked(id, d->checkSpellingEnabled);
+	menu->insertSeparator();
+	id=menu->insertItem(i18n("Allow Tabulations"),this,SLOT(slotAllowTab()));
+	menu->setItemChecked(id, d->allowTabulations);
     }
 
     return menu;
Index: kdeui/ktextedit.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktextedit.h,v
retrieving revision 1.16
diff -u -3 -r1.16 ktextedit.h
--- kdeui/ktextedit.h	2 Jun 2004 15:58:22 -0000	1.16
+++ kdeui/ktextedit.h	13 Jul 2004 09:46:16 -0000
@@ -87,6 +87,21 @@
     bool checkSpellingEnabled() const;
 
     void highLightWord( unsigned int length, unsigned int pos );
+    
+    /**
+     * Enable or disable tabulations in the widget.
+     *
+     * @since 3.3
+     */
+    void setTabulationsEnabled(bool check);
+    
+        /**
+     * Returns true if tabulations are allowed this text edit.
+     *
+     @ see setTabulationsEnabled()
+     * @since 3.2
+     */
+    bool tabulationsEnabled() const;
 
 public slots:
     /**
@@ -153,6 +168,7 @@
     void spellCheckerCorrected( const QString &, const QString &, unsigned int );
     void spellCheckerFinished();
     void toggleAutoSpellCheck();
+    void slotAllowTab();
 
 private:
     void posToRowCol( unsigned int pos, unsigned int &line, unsigned int &col );
Index: khtml/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
--- khtml/rendering/render_form.cpp	22 Jun 2004 05:46:41 -0000	1.264
+++ khtml/rendering/render_form.cpp	13 Jul 2004 09:46:17 -0000
@@ -1201,6 +1201,7 @@
     : KTextEdit(parent), m_findDlg(0), m_find(0), m_repDlg(0), m_replace(0)
 {
     setCheckSpellingEnabled( true );
+    setTabulationsEnabled( false );
 
     if(wrap != DOM::HTMLTextAreaElementImpl::ta_NoWrap) {
         setWordWrap(QTextEdit::WidgetWidth);


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

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