SVN commit 599826 by orlovich: Make sure to let the widgets know about focus changes before the pesky JS can change that, not after the fact when it's prolly no longer true. BUG: 63384 M +21 -0 render_replaced.cpp --- branches/KDE/3.5/kdelibs/khtml/rendering/render_replaced.cpp #599825:599826 @@ -616,6 +616,14 @@ return false; if ( !element() ) return true; + + static bool directToWidget = false; + if (directToWidget) { + //We're trying to get the event to the widget + //promptly. So get out of here.. + return false; + } + ref(); element()->ref(); @@ -624,12 +632,25 @@ //kdDebug() << "RenderWidget::eventFilter type=" << e->type() << endl; switch(e->type()) { case QEvent::FocusOut: + // First, forward it to the widget, so that Qt gets a precise + // state of the focus before pesky JS can try changing it.. + directToWidget = true; + QApplication::sendEvent(m_widget, e); + directToWidget = false; + filtered = true; //We already delivered it! + // Don't count popup as a valid reason for losing the focus // (example: opening the options of a select combobox shouldn't emit onblur) if ( QFocusEvent::reason() != QFocusEvent::Popup ) handleFocusOut(); break; case QEvent::FocusIn: + //As above, forward to the widget first... + directToWidget = true; + QApplication::sendEvent(m_widget, e); + directToWidget = false; + filtered = true; //We already delivered it! + //kdDebug(6000) << "RenderWidget::eventFilter captures FocusIn" << endl; element()->getDocument()->setFocusNode(element()); // if ( isEditable() ) {