Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Remove Focus from WebView Dom
Forum Updated to NodeBB v4.3 + New Features

Remove Focus from WebView Dom

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 563 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    the_master_noob
    wrote on last edited by
    #1

    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

    alt text
    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.

    alt text

    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
    
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved