RESOLVED FIXED 51094
[Qt] No way to set focus to GraphicsWebView with Qt Quick (QML) outside of a mouse click.
https://bugs.webkit.org/show_bug.cgi?id=51094
Summary [Qt] No way to set focus to GraphicsWebView with Qt Quick (QML) outside of a ...
Gary
Reported 2010-12-14 21:19:22 PST
In QML: WebView { id: webView width: 1280 height: 600 url: "http://www.google.com" focus: true } WebView will get the focus, but not the underlining GraphicsWebView. In order for key events to be posted to the GraphicsWebView (and allow for HTML key events to be executed) a user must first click on the WebView to give the GraphicsWebView focus, and then key events will work. My targetted system does not have a mouse, and makes it impossible for a keyboard to post key input to a website that requires key events WITHOUT having a focus html element such as a input box. My work around was to make the GraphicsWebView the Focus Proxy by changing the following init method in qdeclarativewebview.cpp: void QDeclarativeWebView::init() { d = new QDeclarativeWebViewPrivate(this); QWebSettings::enablePersistentStorage(); setAcceptedMouseButtons(Qt::LeftButton); setFlag(QGraphicsItem::ItemHasNoContents, true); setClip(true); d->view = new GraphicsWebView(this); d->view->setResizesToContents(true); QWebPage* wp = new QDeclarativeWebPage(this); setPage(wp); setFocusProxy(d->view); /********************** <---- THIS LINE IS THE WORK AROUND **********************/ connect(d->view, SIGNAL(geometryChanged()), this, SLOT(updateDeclarativeWebViewSize())); connect(d->view, SIGNAL(doubleClick(int, int)), this, SIGNAL(doubleClick(int, int))); connect(d->view, SIGNAL(scaleChanged()), this, SIGNAL(contentsScaleChanged())); } I attached an example. You can navigate between the HTML menu and the QML menu using the left and right keys. You can navigate the QML menu by pressing up and down. You can NOT navigate the HTML menu by pressing up and down, UNTIL you first click on the HTML menu. Then you CAN navigate the HTML menu by pressing up and down.
Attachments
QML Project Code to show Error (28.31 KB, application/x-compressed-tar)
2010-12-14 21:24 PST, Gary
no flags
Make QDeclarativeWebView the focus proxy of QGraphicsWebView (1.57 KB, patch)
2011-01-04 04:36 PST, Girish Ramakrishnan
no flags
Make QGraphicsWebView a FocusScope (1.74 KB, patch)
2011-01-04 06:07 PST, Girish Ramakrishnan
no flags
77882: Make QGraphicsWebView a FocusScope (2) (1.69 KB, patch)
2011-01-04 06:10 PST, Girish Ramakrishnan
hausmann: review+
Gary
Comment 1 2010-12-14 21:24:22 PST
Created attachment 76628 [details] QML Project Code to show Error QML Project: WebKit.qml -- The QML code. Creates 2 menus. One with QML and one with HTML. index.html -- The HTML menu. Uses JavaScript to navigate a menu. jquery-1.4.4.min.js -- JQuery javascript library. Assist in JavaScript development. main.css -- Stylesheets for HTML menu. Launch WebKit.qml with QtCreator or qmlviewer WebKit.qml. You can navigate between the HTML menu and the QML menu using the left and right keys. You can navigate the QML menu by pressing up and down. You can NOT navigate the HTML menu by pressing up and down, UNTIL you first click on the HTML menu. Then you CAN navigate the HTML menu by pressing up and down.
Girish Ramakrishnan
Comment 2 2011-01-04 04:36:57 PST
Created attachment 77877 [details] Make QDeclarativeWebView the focus proxy of QGraphicsWebView Make QDeclarativeWebView the focus proxy of QGraphicsWebView.
Girish Ramakrishnan
Comment 3 2011-01-04 06:07:14 PST
Created attachment 77882 [details] Make QGraphicsWebView a FocusScope Making it a FocusProxy is not the correct fix because it would result in qml 'focus' property returning false even when the view has focus.
Girish Ramakrishnan
Comment 4 2011-01-04 06:10:31 PST
Created attachment 77883 [details] 77882: Make QGraphicsWebView a FocusScope (2) Wrong description and ChangeLog
Simon Hausmann
Comment 5 2011-01-05 01:27:07 PST
Comment on attachment 77883 [details] 77882: Make QGraphicsWebView a FocusScope (2) r=me. ACKed also by Aaron. Would be nice to have a more elaborate changelog entry when landing *hint* *hint* :)
Girish Ramakrishnan
Comment 6 2011-01-05 16:43:44 PST
Landed as r75119
Note You need to log in before you can comment on or make changes to this bug.