July 21, 2011

muchasuerte muchasuerte
Lab Rat
6 posts

Webview keys navigation

 

can I use arrow keys to move focus in a Webview ?

I have to modify in some way the html property of Webview?

  1. import QtQuick 1.0
  2. import QtWebKit 1.0
  3.  
  4. Flickable {
  5.     id: flickable
  6.  
  7.     width: screen.width
  8.     height: screen.height - (toolBar.opacity? toolBar.height:0)
  9.     contentWidth: Math.max(screen.width, web_view1.width)
  10.     contentHeight: Math.max(screen.height, web_view1.height)
  11.     focus: true
  12.  
  13.     WebView {
  14.         id: web_view1
  15.         focus: true
  16.         x: 0
  17.         y: 0
  18.         settings.javascriptEnabled: true
  19.         settings.linksIncludedInFocusChain: true
  20.         opacity: 1
  21.         url: "http://developer.qt.nokia.com/forums/viewforum/12/"
  22.  
  23.         onLoadFinished: console.log("Load Finish!")
  24.         onLoadStarted: console.log("Start Loading..." )
  25.         onAlert: console.log(message)
  26.  
  27.         Keys.onPressed: {
  28.             if (event.key == Qt.Key_PageDown)
  29.             {
  30.                 flickable.contentY =  Math.min(  flickable.contentY + 10, web_view1.height - flickable.height );
  31.             }
  32.             if (event.key == Qt.Key_PageUp)
  33.             {
  34.                 flickable.contentY =  Math.max(  flickable.contentY - 10, 0 );
  35.             }
  36.             console.log("browser" + event.key)
  37.         }
  38.         onUrlChanged: {
  39.             flickable.contentX = 0
  40.             flickable.contentY = 0
  41.         }
  42.         preferredWidth: flickable.width
  43.         preferredHeight: flickable.height
  44.         contentsScale: 1
  45.  
  46.         javaScriptWindowObjects:[
  47.             QtObject {
  48.                 WebView.windowObjectName: "qml"
  49.  
  50.                 function qmlCall() {
  51.                     console.log("This call is in QML!");
  52.                 }
  53.  
  54.             },
  55.             QtObject {
  56.                 WebView.windowObjectName: "console"
  57.                 function log(log) {
  58.                     console.log("log call: "+ log );
  59.                 }
  60.  
  61.             }
  62.         ]
  63.     }
  64. }

0 replies

 
  ‹‹ [SOLVED][Moved] Destroying Objects Based on text and buttons      Reload items of ListView: selected item index resets too ››

You must log in to post a reply. Not a member yet? Register here!