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. Mouse events for rectangles within a flickable
Forum Updated to NodeBB v4.3 + New Features

Mouse events for rectangles within a flickable

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 4 Posters 5.8k 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.
  • Q Offline
    Q Offline
    QtQueries
    wrote on 14 Feb 2011, 15:52 last edited by
    #1

    Hi

    In my QML app, I have a Flickable containing several Rectangles, each of which has a MouseArea filling the whole Rectangle. These Rectangles are serving as buttons, so they move into a "pressed" state on the onPressed event of the MouseArea, and back to "unpressed" on the onReleased event.

    The problem is that if the user presses a button, doesn't release it, and starts flicking, the onReleased event is never fired and my button remains in the "pressed" state.

    I guess this is intended behaviour, because we don't want the button doing its "click" action when only a flick has occurred.

    What's the best way of working round this?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 14 Feb 2011, 16:24 last edited by
      #2

      Hmmm... a workaround may be to reset the state if the parent flickable goes into a flick, for instance by connecting to the onFlickStarted signal.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QtQueries
        wrote on 14 Feb 2011, 16:27 last edited by
        #3

        Yes I feared that might be the case, refactoring to provide all my buttons with access to a Flickable will be a pain.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 14 Feb 2011, 16:38 last edited by
          #4

          I did not claim it is the only way to do it. Just a possibility that occurred to me, though it is not very elegant.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mbrasser
            wrote on 15 Feb 2011, 01:01 last edited by
            #5

            Hi,

            There is an "onCanceled handler":http://doc.qt.nokia.com/4.7-snapshot/qml-mousearea.html#onCanceled-signal that was added for this very reason :-) You could also consider binding the state's when clause to mouseArea.pressed -- it will turn to false when flicked.

            Regards,
            Michael

            1 Reply Last reply
            1
            • 0 Offline
              0 Offline
              0x6368656174
              wrote on 20 Jun 2014, 01:02 last edited by
              #6

              Thanks, really helped.

              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