[Qt-qml] Prevent RMB on top of WebView
Mark Constable
markc at renta.net
Mon Jan 17 08:59:05 CET 2011
On 17/01/11, martin.jones at nokia.com wrote:
> > I have a Rectangle (z:999) on top of a WebView (z:1) inside a
> > Flickable (z:2) and if I use accepted:true inside the onclick
> > handler then it prevents LMB and MMB events from falling through
> > to the WebView item but not RMB events, they still cause the
> > context menu to pop up and activate JS click events on the
> > WebView page underneath.
> >
> > How can I prevent RMB events falling through to a WebView item?
> >
> > Related; how can I modify the WebView context menu options?
>
> You have a MouseArea on top (onClicked)? If so, then setting
> acceptedButtons: Qt.LeftButton | Qt.RightButton will make it
> handle the RMB also.
I am using Qt.RightButton. As below, I can confirm that both
Qt.LeftButton and Qt.MiddleButton are indeed trapped but not
Qt.RightButton. I suspect it's either undocumented behavour
or a (maybe webkit?) bug.
Rectangle {
Flickable {
z: 2
//...
WebView {
z: 1
//...
}
}
Rectangle {
id: webMenu
z: 998
//...
}
Rectangle {
id: topEdge
z: 999
width: c.w
height: 2
color: c.nuColor
opacity: 0.01
visible: true
anchors.top: parent.top
state: "TOPEDGE_CLOSED"
MouseArea {
anchors.fill: parent
hoverEnabled: true
//acceptedButtons: Qt.RightButton
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
onEntered: parent.opacity = 1
onExited: parent.opacity = 0.01
onClicked: {
accepted: true
topEdge.state = (topEdge.state == "TOPEDGE_CLOSED")
? "TOPEDGE_OPEN" : "TOPEDGE_CLOSED"
}
}
states:[
State { name: "TOPEDGE_OPEN"
PropertyChanges { target: webMenu; y: 0 }
},
State { name: "TOPEDGE_CLOSED"
PropertyChanges { target: webMenu; y: -c.menuH }
}
]
}
}
--markc
More information about the Qt-qml
mailing list