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. Wrong mouseButton returned in a WebView after onNavigationRequested
Forum Updated to NodeBB v4.3 + New Features

Wrong mouseButton returned in a WebView after onNavigationRequested

Scheduled Pinned Locked Moved QML and Qt Quick
webviewqmlkde linux distr
2 Posts 1 Posters 1.4k 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.
  • C Offline
    C Offline
    Cqoicebordel
    wrote on 7 Aug 2015, 00:20 last edited by
    #1

    Hi everyone !

    I'm not sure I'm in the right forum, but I'll try anyway.

    I'm developing the Webslice plasmoid that could be found here : http://kde-look.org/content/show.php?content=169878
    It's a simple widget for the KDE desktop allowing to show a webpage that could refresh itself, automagically scroll to an element, etc.

    I was asked to add some new functionalities, like a way to open links in the default browser.
    For that, I added this code in my webview :

    onNavigationRequested: {  
        if (request.navigationType == WebView.LinkClickedNavigation && (request.keyboardModifiers == Qt.ControlModifier || request.mouseButton == Qt.MiddleButton)) {  
            request.action = WebView.IgnoreRequest;  
            Qt.openUrlExternally(request.url);  
        }  
    }  
    

    This code allow a user to middle click a link, or by ctrl+left click, to cancel the navigation in the webview, and to open the clicked link in the default browser.

    The issue is this : request.mouseButton always returns "1" and request.keyboardModifiers always returns "0" whatever the combination of middle click or control I do.

    So I'm asking myself (and you), if I didn't miss a step, or did something wrong. If anyone has an idea, it would be very appreciated. I'm losing my hair on this one.

    (BTW, if you want to see the full QML file, it's here : https://github.com/Cqoicebordel/webslice-plasmoid/blob/master/cqcb.plasma.webslice/contents/ui/main.qml )

    Thanks in advance !

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Cqoicebordel
      wrote on 7 Aug 2015, 18:34 last edited by
      #2

      Since I can't find a solution, I'm trying to do it an other way :

      Intercept ctrl or middle click before they are passed to the webview. For that, I tried to use a mouseArea, but then I'm not able the send back the events to the webview. Even with propagateComposedEvents, and even setting mouse.accepted = false. It looks like mouseArea is stealing everything, and doesn't let any click go to the underlying webview if the button is set in acceptedButtons.

      Do you have an idea to go around that ?

      1 Reply Last reply
      0

      1/2

      7 Aug 2015, 00:20

      • Login

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