Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Bug ? MouseEvent generates Canceled signal if not accepted

Bug ? MouseEvent generates Canceled signal if not accepted

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 879 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    profi-S
    wrote on last edited by
    #1

    Hi,
    I tried to make two overlapped MouseAreas processing the same signals, but seems MouseArea does not propagate signals by default. The "documentation ":http://doc.qt.io/qt-5/qml-qtquick-mouseevent.html#accepted-prop states that mouse event has to be accepted to prevent propagation, but it is accepted also if I have just empty handler processing such signals (Pressed).
    If in onPressed() handler I set accepted to false this cause Canceled signal to be generated ! If we would follow documentation this must just propagate mouse event to another MouseArea

    Simple code for testing :
    @import QtQuick 2.0

    Item{
    width: 300
    height: 300
    Rectangle {
    width: 300
    height: 300
    color: "red"
    MouseArea{
    anchors.fill: parent
    onPressed: {

                console.log("red pressed");
            }
            onReleased: {
                console.log("red released");
            }
            onCanceled: {
                console.log("red canceled");
            }
            onPositionChanged: {
                console.log("red position changed");
            }
        }
    
        Rectangle{
            anchors.centerIn: parent
            width: 100
            height: 100
            color: "green"
            MouseArea{
                anchors.fill: parent
                propagateComposedEvents: true
                onPressed: {
                    mouse.accepted = false;
                    console.log("green pressed");
                }
                onReleased: {
                    console.log("green released");
                }
                onCanceled: {
                    console.log("green canceled");
                }
                onPositionChanged: {
                    console.log("green position changed");
                }
            }
        }
    }
    

    }

    @

    I click on the green rectangle, this code would produce log:

    green pressed
    green cancled
    red pressed
    red released

    At the moment I do not have idea if this is a bug or not, and how to make overlapped mouseareas to process same event.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      bq. If in onPressed() handler I set accepted to false this cause Canceled signal to be generated ! If we would follow documentation this must just propagate mouse event to another MouseArea

      It will not as "propagateComposedEvents":http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#propagateComposedEvents-prop only works for composed events and pressed is not a composed event.

      From the Doc:

      bq. MouseArea contains several composed events: clicked, doubleClicked and pressAndHold. These are composed of basic mouse events, like pressed, and can be propagated differently in comparison to basic events.

      157

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved