omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    touch_id how to use this

    Pythonista
    4
    4
    3130
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • st3v3_42
      st3v3_42 last edited by

      Hello

      I have a program where I am trying to control two objects on either side of the screen. Pythonista's help file suggests using the touch_id attribute. However I do not (nor can I find) any way to determine what each touch_id is nor assign it a particular ID.

      If anyone could help by perhaps providing some simple code that explains how the touch_id works it would be most appreciated!

      Thank You all!

      1 Reply Last reply Reply Quote 0
      • polymerchm
        polymerchm last edited by

        Look at @JonB's code here regarding multi-touch for zooming.

        1 Reply Last reply Reply Quote 0
        • JadedTuna
          JadedTuna last edited by

          Hey there. touch_id is basically an ID for every touch - you can have any amount of touches and all of them will have an unique touch_id. It can be used in multi-touch applications to track down different touches.

          1 Reply Last reply Reply Quote 0
          • JonB
            JonB last edited by

            A few rules that may be helpful:

            1. touch_began always gets called the first time in new touches. That's a good time to add the Touch ID to a list. Sometimes you want to keep track of the initial touch location, rather than incremental changes, and this would be the time for that as well.

            2. whenever a touch moves, touch_moved gets called. Here you would lookup the Touch ID and update whatever logic you have that depends on the touch location. note that the order of touch calls in not guaranteed, and there is no way to know how many fingers there are on the screen except by counting how many items you have in your local touch list.
              Note the incremental direction can be found by differencing the location from previous location. There is no guarantee how often this function is called. for some purposes it is useful to check for some minimum motion before taking action, in which case it works better to keep track of the initial touch yourself.
              For gestures, you would probably keep a history of touch locations, or keep track of direction changes.

            3. when a touch lifts, touch_ended is usually called. Now would be the time to take any final action, then delete the unused touch from your touch lists. There are unfortunately exceptions to this... For instance for panel presentation types, pythonista grabs control of the touches when sliding back to the editor, and so touch_ended does not get called. Therefore, for some applications it is advisable to have a timer that gets kicked off which clears out inactive touches, which gets restarted every time a touch moves. Hopefully this bug gets fixed, because currently touch is basically unusable in panel style presentation.

            4. remember that multitouch with more than 2 fingers can sometimes conflict with ios gestures, so you may want to turn those off.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors