Below is my WebEngineView (QML) . If the selection is enabled, then this mousearea is not considered. When the mousearea is active, selection is inactive.
I dont understand, why fewer times, mousearea defined inside WebEngineView is enabled and rest of times mousearea defined is not enabled.
WebEngineView {
id: currentWebview
objectName: "webView"
url: "http://www.google.co.in"
anchors.fill: parent
readonly property string htmlContent: content
onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
MouseArea {
id : mousearea
anchors.fill: parent
drag {
id : weDrag
target: currentWebview
}
onPressed: {
pressPoint.x = mouseX
pressPoint.y = mouseY
console.log("PressPoint : "+pressPoint)
}
onReleased: {
releasePoint.x = mouseX
releasePoint.y = mouseY
console.log("releasePoint : "+releasePoint)
if(pressPoint != releasePoint )
{
currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
}
}
}
}
WebEngineView {
id: currentWebview
objectName: "webView"
url: "http://www.google.co.in"
anchors.fill: parent
readonly property string htmlContent: content
onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
MouseArea {
id : mousearea
anchors.fill: parent
drag {
id : weDrag
target: currentWebview
}
onPressed: {
pressPoint.x = mouseX
pressPoint.y = mouseY
console.log("PressPoint : "+pressPoint)
}
onReleased: {
releasePoint.x = mouseX
releasePoint.y = mouseY
console.log("releasePoint : "+releasePoint)
if(pressPoint != releasePoint )
{
currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
}
}
}
}
To copy to clipboard, switch view to plain text mode
Added after 10 minutes:
Originally Posted by
wysota
You put a mouse area over the item and handle things there. But you don't have to repeat what the view already handles itself. Just pass in the events you are not handling yourself in the mouse area.
how do pass in the events which I am not handling.
in QGraphicsWebView, we pass in the mouse events as QGraphicsWebView::mousePresses(event).
Here how do I do the same.
Also I am not able to capture the selected text.
how can I do that.
onReleased: {
releasePoint.x = mouseX
releasePoint.y = mouseY
console.log("releasePoint : "+releasePoint)
if(pressPoint != releasePoint )
{
currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
}
}
onReleased: {
releasePoint.x = mouseX
releasePoint.y = mouseY
console.log("releasePoint : "+releasePoint)
if(pressPoint != releasePoint )
{
currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
}
}
To copy to clipboard, switch view to plain text mode
I tried something as above, when this signal is captured, selection is not enabled.
When selection is enabled, this signal (ie) mousearea defined is not enabled
Bookmarks