July 7, 2012

giovannie giovannie
Lab Rat
14 posts

MouseArea pressedButtons

 

Hello.

  1. import QtQuick 1.1
  2.  
  3. Text {
  4.  text: mouseArea.pressed
  5.  
  6.  MouseArea {
  7.   id: mouseArea
  8.   anchors.fill: parent
  9.  }
  10. }

First I press left mouse button and I see true.
Then I press right mouse button still holding left button and I see true.
Then I release right mouse button still holding left button and I see false.

Anybody knows why?

It is Qt 4.8.2 QtQuick 1.1 on windows with mingw.

Using pressedButtons property also give strange results with multiple buttons pressed.

4 replies

July 7, 2012

raaghuu raaghuu
Hobby Entomologist
115 posts

it seems that both mouse buttons pressed simultaneously are taken to be another button(because pressedButtons consists of bitwise combination of buttons)if considered together… right and left pressed together amount to a value of ‘3’… if you want to check if a button is pressed or not, you should use something like:

  1. if(pressedButtons & Qt.LeftButton)
  2. //... code here

July 7, 2012

Bomb3rman Bomb3rman
Ant Farmer
39 posts

Well the problem is, that you get a release event for the right mouse button, but no pressed event. Instead of the pressed event there is a context menu event.
What happens is, the left button is pressed, then you press the right button and release it again. The release of the right button sets the internal state to not pressed.
I think this can be considered as bug…

July 9, 2012

mbrasser mbrasser
Ant Farmer
452 posts

I agree that sounds like a bug — could you add a new bug via http://bugreports.qt-project.org please?

July 9, 2012

giovannie giovannie
Lab Rat
14 posts

pressedButtons & Qt.LeftButton don’t work too but in a different way.
It stay true after releasing right mouse button but then releasing left button it is not reset.

Bugreport here https://bugreports.qt-project.org/browse/QTBUG-26458

 
  ‹‹ How to Hide Window flags in qt Quick?      QML state changes on double click ››

You must log in to post a reply. Not a member yet? Register here!