Remove Focus from WebView Dom
Unsolved
QML and Qt Quick
-
Im trying to use Video-js in Webview for Android TV before i can start the Video i need to press the big play button on the side
But when i press the focus stays inside Webview Dom how i can remove focus from Webview and give it to the Qml Controls Slider.
I try it :
webViewId.focus = false
webViewId.activeFocus = false
progressbarId.focus = true
progressbarId.activeFocus = true
progressbarId.forceActiveFocus()Still Doe not Work Webview Dom has focus
When i press the android Directional pad keys it just moves the page up and down.Is it possiple if u press something in Webview to give focus back to element inside Qml ?
import QtQuick 2.15 import QtQml 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.5 import QtWebView 1.1 Item { property alias weburl: webViewId.url WebView { id: webViewId width: parent.width height: parent.height - controllerId.height Timer { id: isvideostartedplaying repeat: true interval: 1000 // 1 second onTriggered:{ webViewId.runJavaScript("myPlayer.paused()", function(result){ if (result === false){ brogresbartimeId.start() // Here im Trying to change Focus to the Slider // webViewId.focus = false webViewId.activeFocus = false progressbarId.focus = true progressbarId.activeFocus = true progressbarId.forceActiveFocus() ////////////////////////////////////////////////// playButtonId.isClicked = true isvideostartedplaying.repeat = false } }); } } // Timer - isvideostartedplaying onLoadingChanged: { if (loadRequest.status == WebView.LoadSucceededStatus) { webViewId.runJavaScript("myPlayer.paused()", function(result){ if(result === true){ isvideostartedplaying.start() webViewId.runJavaScript("durationVid()", function(result){ progressbarId.to = (result/1000) }); } }); } } Rectangle { color: "black" width: parent.width height : 45 anchors.top: webViewId.bottom Row { id : controllerId anchors.fill: parent anchors.margins : 3 Button { property bool isClicked: true id: playButtonId icon.color: focus ? "red" : "lightgray" icon.name: "play" icon.source: isClicked? "qrc:/image/play.png" : "qrc:/image/pause.png" icon.width: 20 icon.height: 20 background: Qt.transparent onPressed: { playButtonId.isClicked = !playButtonId.isClicked webViewId.runJavaScript("myPlayer.paused()", function(result){ if(result === true){ //webViewId.forceActiveFocus() webViewId.runJavaScript("playVid()", function(result){consollog(result)}); //playButtonId.forceActiveFocus() } if (result === false){ //webViewId.forceActiveFocus() webViewId.runJavaScript("pauseVid()", function(result){consol.log(result)}); //playButtonId.forceActiveFocus() } }); } } //Play Button Slider { id: progressbarId width: parent.width - (playButtonId.implicitWidth + volumeButoonId.implicitWidth + volumeSliderId.width) anchors.verticalCenter: playButtonId.verticalCenter live: true from: 0 focus: true Timer { id: brogresbartimeId repeat: true interval: 1000 // 1 second onTriggered:{ webViewId.runJavaScript("myPlayer.remainingTime()", function(result){ progressbarId.value = progressbarId.to - (result/1000) }); } } onMoved: { var settime = "myPlayer.currentTime(" + (value * 1000) + ")" webViewId.runJavaScript(settime, function(result){consol.log(result)}); webViewId.runJavaScript("myPlayer.ended()", function(result){ if(result === false){ webViewId.runJavaScript("playVid()", function(result){consol.log(result)}); playButtonId.isClicked = false } }); } } // Slider Button { id: volumeButoonId icon.color: focus ? "red" : "lightgray" icon.name: "Volume Button" icon.source: "qrc:/image/volume-adjustment.png" icon.width: 20 icon.height: 20 background: Qt.transparent } //Volume Button ProgressBar { id: volumeSliderId width: 100 anchors.verticalCenter: volumeButoonId.verticalCenter from: 0 to: 1 } // Voulme Progess Ba } // Row } // Rectangle } //WebView }