[Qt-qml] How to ignore MouseArea signals

martin.jones at nokia.com martin.jones at nokia.com
Wed Dec 8 03:41:44 CET 2010


Log a bug.  It would be good if you could suggest where the docs are lacking - i.e. where you started looking when this didn't work as expected.  The "accepted" behavior is documented in the MouseArea signal documentation.

BR,
Martin.

> -----Original Message-----
> From: ext Halton Huo [mailto:halton.huo at intel.com]
> Sent: Wednesday, 8 December 2010 11:56 AM
> To: Jones Martin (Nokia-MS-Qt/Brisbane)
> Cc: adriano.rezende at openbossa.org; qt-qml at trolltech.com
> Subject: RE: [Qt-qml] How to ignore MouseArea signals
> 
> Woo, OnPressed works, thanks very much.
> 
> The document need to be improved. Any process to do that?
> 
> Cheers,
> Halton.
> On Wed, 2010-12-08 at 09:46 +0800, martin.jones at nokia.com wrote:
> > You need to accept in onPressed.  accepted is ignored for any other event.
> >
> > BR,
> > Martin.
> >
> >
> > > -----Original Message-----
> > > From: qt-qml-bounces at trolltech.com [mailto:qt-qml-bounces at trolltech.com]
> On
> > > Behalf Of ext Halton Huo
> > > Sent: Wednesday, 8 December 2010 11:42 AM
> > > To: Adriano Rezende
> > > Cc: qt-qml at trolltech.com
> > > Subject: Re: [Qt-qml] How to ignore MouseArea signals
> > >
> > > "enabled" does not match my case.
> > >
> > > I need receive the MouseArea signals but as well as those below the top
> > > item can receive the signals also.
> > >
> > > Refer to MouseEvent element document, seems accepted can do that.
> > > ---------
> > > accepted : bool
> > >
> > > Setting accepted to true prevents the mouse event from being propagated
> > > to items below this item.
> > >
> > > Generally, if the item acts on the mouse event then it should be
> > > accepted so that items lower in the stacking order do not also respond
> > > to the same event.
> > >
> > >
> > > But following code does not work as I wish
> > >         MouseArea {
> > >             anchors.fill: parent
> > >             onClicked: {
> > >                 console.log("mouse.accepted="+mouse.accepted)
> > >                 mouse.accepted = false
> > >                 console.log("mouse.accepted="+mouse.accepted)
> > >             }
> > >         }
> > >
> > > Thanks,
> > > Halton.
> > >
> > > On Wed, 2010-12-08 at 02:55 +0800, Adriano Rezende wrote:
> > > > On Tue, Dec 7, 2010 at 4:31 AM, Halton Huo <halton.huo at intel.com> wrote:
> > > > > So my questions how to ignore the received signals to let other items to
> > > > > continue deal with those signals?
> > > >
> > > > You can set enabled property to false or ignore the event on mouse press.
> > > >
> > > > MouseArea {
> > > >     anchors.fill: parent
> > > >     onClicked: console.log("background clicked");
> > > > }
> > > >
> > > > MouseArea {
> > > >     anchors.fill: parent
> > > >     enabled: false
> > > >     //onPressed: mouse.accepted = false;
> > > >     onClicked: console.log("foreground clicked");
> > > > }
> > > >
> > > > Br,
> > > > Adriano
> > >
> > >
> > > _______________________________________________
> > > Qt-qml mailing list
> > > Qt-qml at trolltech.com
> > > http://lists.trolltech.com/mailman/listinfo/qt-qml
> 





More information about the Qt-qml mailing list