Forums

OverviewFelgo 2 Support (Qt 5) › Press & Hold on SimpleRow

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15305

    Nicola

    Hi,

    How is possible implement the Press&Hold on SimpleRow. I tryed to connect a MouseArea on the Row, but i don’t have the “visual effect” and it’s not possible connect the mousearea ot the default textItem because they are not sibling. Is existing a solution for this?

    Thanks

    Nicola

    #15306

    Günther
    Felgo Team

    Hi Nicola!

    Unfortunately the SimpleRow does not support connecting the pressAndHold signal at the moment. We should probably add this feature to the component, until then you can use the following “hack” to add the feature with a custom Background/MouseArea and pressed-effects to the SimpleRow:

    SimpleRow {
      id: row
      
      // new pressAndHold signal
      signal pressAndHold(int index)
      
      // custom background for hover effect (non-Android)
      Rectangle {
        width: parent.width
        height: parent.height - px(row.style.dividerHeight)
        radius: parent.radius
        
        color: !Theme.isAndroid && customMouseArea.pressed ? row.style.selectedBackgroundColor : row.style.backgroundColor
        Behavior on color {
          ColorAnimation { duration: 150; easing.type: Easing.InOutQuad }
        }
      }
      
      // custom mousearea with Android Ripple Effect to replace the internal one
      RippleMouseArea {
        id: customMouseArea
        anchors.fill: parent
        enabled: row.enabled
        circularBackground: false
        radius: parent.radius
        
        // use selected background color of the style for the ripple background
        backgroundColor: setAlpha(row.style.selectedBackgroundColor, 0.5)
        fillColor: setAlpha(row.style.selectedBackgroundColor, 0.5)
        
        function setAlpha(color, alpha) {
          return Qt.rgba(color.r,color.g,color.b, alpha)
        }
        
        // fire simple-row signals
        onReleased: row.selected(typeof index !== "undefined" ? index : 0)
        onPressAndHold: row.pressAndHold(typeof index !== "undefined" ? index: 0)
      }
      textItem.parent.parent.parent.z: 1 // brings content of row to front (above custom background & mousearea)
      
      // you can now freely handle item selected or press and hold
      onSelected: console.log("SELECTED: "+index)
      onPressAndHold: console.log("PRESS AND HOLD: "+index)
    }

     

    Sorry that we have no better solution for this at the moment!

    Best,
    Günther

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support