Notices


Reply
Thread Tools
Markkyboy's Avatar
Posts: 279 | Thanked: 370 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#1
Hi all,

as per the title of this post, I'm wanting to decrease the duration of 'onPressAndHold', I've found a few suggestions on StackExchange but have not been able to make it work for my case.

Rather than posting any and all attempts I've made, I'd like to make it work with what little I have originally coded so far, but the duration is a tad too long; how do I reduce the duration?......

Code:
    MouseArea {
          anchors.fill: root
          propagateComposedEvents: true
          onPressAndHold: view.closeTab(index)
    }
}
I understand that perhaps a 'Timer' needs to be used, but I just cannot fathom how to do it, any ideas gratefully received!
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
coderus's Avatar
Posts: 6,139 | Thanked: 11,594 times | Joined on Nov 2011 @ Open Mobile Platform, Innopolis, Russia
#2
onPressed: timer.start()
onReleased: timer.stop()
onCancel: timer.stop()
timer.onTriggered: view.closeTab(index)
__________________
Twitter | Openrepos | GitHub | PayPal.Me

Last edited by coderus; 2018-07-20 at 09:38.
 

The Following 7 Users Say Thank You to coderus For This Useful Post:
Markkyboy's Avatar
Posts: 279 | Thanked: 370 times | Joined on Oct 2012 @ Costa Blanca, Espaņa
#3
Originally Posted by coderus View Post
onPressed: timer.start()
onReleased: timer.stop()
onCancel: timer.stop()
timer.onTriggered: view.closeTab(index)
Perfect!, I was fairly close with one of my attempts, but you have succeeded where I failed (again) and all with less code than I had applied.

Eventually........

Code:
        MouseArea {
            anchors.fill: root
            propagateComposedEvents: true
            onPressed: {
                timer.start();
            }
            onReleased: {
                timer.stop();
            }
            Timer {
                id: timer
                interval: 500
                onTriggered: {
                    view.closeTab(index)
                }
            }
        }
......this will evolve

Thanks again, coderus

Regards,
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
coderus's Avatar
Posts: 6,139 | Thanked: 11,594 times | Joined on Nov 2011 @ Open Mobile Platform, Innopolis, Russia
#4
add timer stop to onCanceled and onExited
__________________
Twitter | Openrepos | GitHub | PayPal.Me
 

The Following 3 Users Say Thank You to coderus For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 03:52.