From f5cd1502012a4a23def9798c46d46d9b9b81a890 Mon Sep 17 00:00:00 2001 From: Julian Depetris Chauvin Date: Sat, 3 Sep 2011 11:45:43 -0300 Subject: [PATCH] Regression: Fix "can't go up/down the list of suggestions" bug introduced while fixing "sync between currently active article and the 'found in dictionaries' pane for web dictionaries" bug. See other focusReasons at http://doc.qt.nokia.com/4.7-snapshot/qt.html#FocusReason-enum --- article_maker.cc | 2 +- articlewebview.cc | 17 +++++++++++++++++ articlewebview.hh | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/article_maker.cc b/article_maker.cc index 2663ae82..b249bd9b 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -101,7 +101,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, "function processIframeMouseOut() { overIframeId = null; top.focus(); }" "function processIframeMouseOver( newId ) { overIframeId = newId; }" "function processIframeClick() { if( overIframeId != null ) { overIframeId = overIframeId.replace( 'gdexpandframe-', '' ); gdMakeArticleActive( overIframeId ) } }" - "function init() { window.addEventListener('blur', processIframeClick, false); top.focus(); }" + "function init() { window.addEventListener('blur', processIframeClick, false); }" "window.addEventListener('load', init, false);" ""; diff --git a/articlewebview.cc b/articlewebview.cc index 943fb01c..1494b792 100644 --- a/articlewebview.cc +++ b/articlewebview.cc @@ -38,3 +38,20 @@ void ArticleWebView::mouseDoubleClickEvent( QMouseEvent * event ) } } + +void ArticleWebView::focusInEvent( QFocusEvent * event ) +{ + QWebView::focusInEvent( event ); + + switch( event->reason() ) + { + case Qt::MouseFocusReason: + case Qt::TabFocusReason: + case Qt::BacktabFocusReason: + page()->mainFrame()->evaluateJavaScript("top.focus();"); + break; + + default: + break; + } +} diff --git a/articlewebview.hh b/articlewebview.hh index 6f67d9da..1d362a1c 100644 --- a/articlewebview.hh +++ b/articlewebview.hh @@ -38,6 +38,7 @@ protected: void mousePressEvent( QMouseEvent * event ); void mouseReleaseEvent( QMouseEvent * event ); void mouseDoubleClickEvent( QMouseEvent * event ); + void focusInEvent( QFocusEvent * event ); private: