Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [sovled][Windows Phone 8.1][5.4] QML MouseArea pressAndHold signal not working properly.
Forum Updated to NodeBB v4.3 + New Features

[sovled][Windows Phone 8.1][5.4] QML MouseArea pressAndHold signal not working properly.

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 4 Posters 1.6k 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.
  • K Offline
    K Offline
    kolegs
    wrote on last edited by
    #1

    Hey,

    I got a problem with pressAndHold signal in mouseArea. The problem is that signal is emitted right after clicking on the area instead after some time(800ms according to documentation http://doc.qt.digia.com/qt-5.2/qml-qtquick-mousearea.html#onPressAndHold-signal).

    So got a question, is there a way to manually set the long press time? I think this could fix it.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK no, it's a constant that cannot be currently changed

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alexleutgoeb
        wrote on last edited by
        #3

        Hi,

        I also experienced that issue, this seems to be a bug in the Win RT port.

        As a workaround you can add your own timer and kind of simulate the pressAndHold behavior like the following code snippet (this snippet also handles the clicked signal, you can strip some code if you don't need that):

        @MouseArea {
        id: innerArea

        // Internal properties for pressAndHold handling
        property bool __isLongPress: false
        property real __initialY: 0
        
        onClicked: {
          // Don't handle clicked signal if it is a long press
          if (__isLongPress)
            return
        
          // Handle the clicked signal here
        }
        
        onPressed: {
          if (!pressAndHoldTimer.running) {
            __isLongPress = false
            pressAndHoldTimer.restart()
            __initialY = mouseY
          }
        }
        
        onReleased: {
          if (pressAndHoldTimer.running) {
            pressAndHoldTimer.stop()
          }
        }
        
        onPositionChanged: {
          // Check for some absolute movement before canceling timer
          if (pressAndHoldTimer.running && Math.abs(mouseY - __initialY) > 10) {
            pressAndHoldTimer.stop()
          }
        }
        
        Timer {
          id: pressAndHoldTimer
        
          interval: 800
        
          onTriggered: {
            innerArea.__isLongPress = true
            
            // Handle the pressAndHold signal here
          }
        }
        

        }@

        You can also up-vote the bug report here to get it fixed faster: https://bugreports.qt.io/browse/QTBUG-44606

        Cheers,
        Alex from V-Play

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kolegs
          wrote on last edited by
          #4

          Thanks for help, had same idea as you, but I wasnt sure if its a bug or my mistake.

          Anyway I think it's solved since there is simple workaround. But still I up-voted the bug.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lynic
            wrote on last edited by
            #5

            The bug has been fixed a few weeks ago in the Qt 5.4.1 version.

            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