Bug 324535 - Add property 'pressedButtons' to MouseArea
Summary: Add property 'pressedButtons' to MouseArea
Status: RESOLVED UNMAINTAINED
Alias: None
Product: QmlWeb
Classification: Unmaintained
Component: QtQuick (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: NOR task
Target Milestone: ---
Assignee: Anton Kreuzkamp
URL:
Keywords: junior-jobs
Depends on:
Blocks: 331214
  Show dependency treegraph
 
Reported: 2013-09-05 10:16 UTC by Anton Kreuzkamp
Modified: 2025-06-10 16:57 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Proposed Patch (1.46 KB, patch)
2014-04-05 20:20 UTC, Harsh Choudhary
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Kreuzkamp 2013-09-05 10:16:21 UTC
In QtQuick MouseArea has a property 'pressed' indicating if the user is currently holding the mouse button pressed on this mouse area. QmlWeb is currently missing it.
Comment 1 Thomas McGuire 2013-09-24 11:21:33 UTC
There is more stuff in MouseArea that I was missing, btw. I think I was missing the onPositionChanged signal (or alternatively the properties mouseX and mouseY together with their changed signals)
Comment 2 Anton Kreuzkamp 2013-09-24 21:40:11 UTC
I added this one as a single task, because I think it's an ideal entry point to start hacking on QmlWeb.
Comment 3 Gursheel Singh 2014-03-24 12:45:42 UTC
Hey! I am new to open source projects. This would be my first one. How do i start contributing to it? As in how do I see the code having the bug? How do I edit that?
Thanks!
Comment 4 Anton Kreuzkamp 2014-03-24 19:19:30 UTC
Hi,
thanks a lot for your interest in contributing to QmlWeb! :)
Actually this task turned out to be quite hard. The property 'pressed' is implemented and there's no bug about that, the only problem left, is that in QtQuick there's a signal with the same name, which makes it hard to implement both properly.

Instead I'd propose implementing the property 'pressedButton'. That one is still missing. It would be an ideal entry point :)

First of all, you will have to get the source code of QmlWeb using git, from https://projects.kde.org/projects/playground/www/qmlweb/repository (If you don't know git, yet: http://git-scm.com/book/en/Getting-Started-About-Version-Control and http://git-scm.com/book/en/Getting-Started-Installing-Git)
The next step is to open the source file src/qtcore.js and search for the function called QMLImage. You will understand how to add a new property and how to set it, when needed (when the mouse was pressed/released on the HTML/DOM element). You should moreover adjust the test/testpad/mousearea.qml and add some simple feedback to test if the property works as intended (it's totally up to you, how to test it, the tests we have are currently quite bad, so no high standards there ;)) You can call the test, by accessing test/testpad/viewer.html#mousearea.qml with your webbrowser.

When you finished the edit, you need to create a diff-file. You can do so using `git diff > mypatch.diff`.
The next step is to go to reviewboard.kde.org, login and file a review request to QmlWeb, providing your diff-file. I will then have a look at it , comment on it and for the beginning I'll commit them, as soon as they're good enough to be included in QmlWeb.

When you have done a few contributions, you may apply for a KDE developer account, enabling you to commit your patches yourself, directly. :) (http://techbase.kde.org/Contribute/Get_a_Contributor_Account)
Comment 5 Harsh Choudhary 2014-04-03 02:55:40 UTC
I saw the qtcore.js file and pressed is already implemented in QMLMouseArea. QMLImage has no such property and not even a clicked signal but I don't think that is needed if we can implement MouseArea in it. Did I understand it wrong? Please clear my doubt.
Comment 6 Anton Kreuzkamp 2014-04-03 16:40:36 UTC
Oh, yes, that was a typo, actually. I meant QMLMouseArea. It does have 'pressed' already, but doesn't have 'pressedButtons' yet.
I changed the summary of this bug, to refer to 'pressedButtons'.
Comment 7 Harsh Choudhary 2014-04-04 06:16:00 UTC
What does 'pressedButtons' supposed to do? What is the difference between pressed and pressedButton?
Comment 8 Anton Kreuzkamp 2014-04-04 20:48:31 UTC
pressed is a boolean just stating true or false, whether a mouse button is currently pressed down or not, while pressedButtons is a flags value, containing exactly which buttons are pressed.
For details, see: http://qt-project.org/doc/qt-4.8/qml-mousearea.html#pressedButtons-prop
Comment 9 Harsh Choudhary 2014-04-05 20:20:07 UTC
Created attachment 85969 [details]
Proposed Patch

I have added the property 'pressedButtons' in QMLMouseArea. On mousedown, I'm assigning the mouse button pressed and on mouse up it is being assigned the value -1. Please tell if I did it right.
Comment 10 Anton Kreuzkamp 2014-04-06 21:20:27 UTC
Thanks a lot for the patch. :) :) :)

The principle is right. :)
But you have to not use mouse.button but mouse.buttons, in order to get all buttons that are pressed. mouse.buttons does not exist currently, so that would be the ideal point to change that. :D
The principle would be similar to what is done for mouse.button, only using e.buttons and instead of checking if e.buttons is == some value, you'd have to check if it contains some value using the & operator. Moreover the individual values need to be combined using the | operator.

The second thing is, that you should not reset the value to -1 on release, but to 0.

Ideally you should use http://reviewboard.kde.org to post your patch for review :) (You can use the same login credentials like here)
Comment 11 Christoph Cullmann 2025-06-10 16:57:29 UTC
This project is unfortunately no longer maintained.

If a new maintainer wants to step up and take care, the project is archived here:

https://invent.kde.org/unmaintained/qmlweb

You can just clone it in your private namespace on invent.kde.org and if you have started to work on it and fixed/implemented something get it reviewed and the project unarchived.

Sorry for the inconveniences.