Announcement

Collapse
No announcement yet.

Touch and Hold Button

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Touch and Hold Button

    I was experimenting with the touchscreen functions and I would like to know why there is no way to perform a Touch and Hold type function.

    It seems as though once you have retrieved the "PRESSED" state of the touchscreen, it re-initialises to INVALID/NOTOUCH on the second pass through even though there has been no release of the touchscreen

    If it is not too much effort, I think I would like to see 5 states, INVALID, PRESSED, HELD,  RELEASED, MOVING this should not affect existing touchscreen code implemented by others since they are likely using if(pressed) if(released) type setup..

    Comments??

    THanks

    Andy
    MicroLec Industries P/L
    www.intelligym.com.au

  • #2


    Hi Andy,
    Although polling for a 'held' event can be done with a flag, there is never really any need to poll it as the touch event loop should be a 'master event loop', not a slave function. The attached code should help to clarify this.



    Attached files TouchEvents.4dg (2.8 KB)
    Regards,
    Dave

    Comment


    • #3


      hahaha a flag.. of course..  My initial though process was that it was continually going to be spat into "TOUCH_PRESS" and when I found that was reset, I automatically jumped straight to the conclusion of another state.

      After some more playing it's interesting to note that if one was not intending on using any actual "Moving" type interface, you could use the MOVING state to signify a held state, since it is rare that you can hit precisely a single touch pixle... something to think about anyways.

      Thanks for that. Here's a "held / hold example"

      Andy


      Attached files TouchHold.4dg (3.5 KB)
      MicroLec Industries P/L
      www.intelligym.com.au

      Comment


      • #4


        Yeah exactly. Also worth noting, if you just needed a simple tap detection to exit a program or progress past a prompt, its easy to just do this:-

        touch_Set(TOUCH_ENABLE); // enable the touch screen
        while(touch_Get(TOUCH_STATUS) != TOUCH_PRESS); // wait for a tap
        touch_Set(TOUCH_DISABLE); // finished
        Regards,
        Dave

        Comment

        Working...
        X