Wrong mouseButton returned in a WebView after onNavigationRequested
-
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 !
-
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 settingmouse.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 inacceptedButtons
.Do you have an idea to go around that ?