Active Topics

 


Reply
Thread Tools
Markkyboy's Avatar
Posts: 433 | Thanked: 727 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!
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#2
onPressed: timer.start()
onReleased: timer.stop()
onCancel: timer.stop()
timer.onTriggered: view.closeTab(index)
__________________
Telegram | Openrepos | GitHub | Revolut donations

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: 433 | Thanked: 727 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,
__________________
..oO(Don't just sit there standing around, pick up a shovel and sweep up!)Oo..
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
coderus's Avatar
Posts: 6,436 | Thanked: 12,699 times | Joined on Nov 2011 @ Ängelholm, Sweden
#4
add timer stop to onCanceled and onExited
__________________
Telegram | Openrepos | GitHub | Revolut donations
 

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 06:29.