Suggested fix for 60403 (document.onkeypress prevents key_up/key_down etc.).

David Faure faure at kde.org
Thu Oct 23 12:45:16 BST 2003


A simple "!" change in logic fixes 60403 (see testcase there).

--- khtmlview.cpp       20 Oct 2003 21:10:37 -0000      1.570
+++ khtmlview.cpp       23 Oct 2003 11:41:02 -0000
@@ -921,12 +921,13 @@ void KHTMLView::keyPressEvent( QKeyEvent
                return;
            }
        }
-        if (!_ke->text().isNull() && m_part->xmlDocImpl()->getHTMLEventListener(EventImpl::KHTML_KEYDOWN_EVENT))
-            if (m_part->xmlDocImpl()->documentElement()->dispatchKeyEvent(_ke))
-            {
+        if (!_ke->text().isNull() && m_part->xmlDocImpl()->getHTMLEventListener(EventImpl::KHTML_KEYDOWN_EVENT)) {
+            // If listener returned false, stop here. Otherwise handle standard keys (#60403).
+            if (!m_part->xmlDocImpl()->documentElement()->dispatchKeyEvent(_ke)) {
                 _ke->accept();
                 return;
             }
+        }
     }

     int offs = (clipper()->height() < 30) ? clipper()->height() : 30;

What can be a bit surprising is that the code right before it says
            if (d->lastKeyNode->dispatchKeyEvent(_ke)) {
		_ke->accept();
		return;
	    }

But I think that's because in that case it's another node, so if it accepts the
event we're all done. In the patch it's about the view itself, so if it doesn't
abort the event we can handle keydown/keyup etc.
Koos, this code is from you: any objections?

-- 
David FAURE, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kfm-devel mailing list