Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    Decrease onPressAndHold duration

    Reply
    Markkyboy | # 1 | 2018-07-20, 08:04 | Report

    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!

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
    imaginaryenemy, juiceme

     
    coderus | # 2 | 2018-07-20, 09:25 | Report

    onPressed: timer.start()
    onReleased: timer.stop()
    onCancel: timer.stop()
    timer.onTriggered: view.closeTab(index)

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by coderus; 2018-07-20 at 09:38.
    The Following 7 Users Say Thank You to coderus For This Useful Post:
    imaginaryenemy, juiceme, Markkyboy, pasko, pichlo, rinigus, taixzo

     
    Markkyboy | # 3 | 2018-07-20, 14:20 | Report

    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,

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
    imaginaryenemy, juiceme

     
    coderus | # 4 | 2018-07-20, 16:51 | Report

    add timer stop to onCanceled and onExited

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 3 Users Say Thank You to coderus For This Useful Post:
    imaginaryenemy, juiceme, pasko

     
vBulletin® Version 3.8.8
Normal Logout