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. In MouseArea.onEntered, detect if the cause is only that the *MouseArea* moved and came to be under the cursor
Forum Updated to NodeBB v4.3 + New Features

In MouseArea.onEntered, detect if the cause is only that the *MouseArea* moved and came to be under the cursor

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
mouseeventinput
1 Posts 1 Posters 575 Views 1 Watching
  • 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.
  • Stefan Monov76S Offline
    Stefan Monov76S Offline
    Stefan Monov76
    wrote on last edited by Stefan Monov76
    #1

    In MouseArea.onEntered, can I detect if the cause for the event firing is only that the MouseArea moved and came to be under the cursor, rather than the other way round?

    I thought of doing something like this: (pseudocode)

        MouseArea {
            // ...
            property bool positionDirty = false
            Connections {
                target: window
                onAfterRendering: {
                    positionDirty = false;
                }
            }
            onMouseAreaPosChanged: {
                positionDirty = true;
            }
            onEntered: {
                if(positionDirty) {
                    positionDirty = false;
                    return;
                }
                // handle event here
            }
        }
    

    But this makes the assumption that entered will be fired after mouseAreaPosChanged, and before window.afterRendering. And I'm not confident in that assumption.

    Also, it doesn't work when an ancestor of the MouseArea moves, or when the MouseArea is positioned/sized via anchoring.

    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