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.


    Gestures - updated with delegates

    Pythonista
    1
    1
    921
    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.
    • mikael
      mikael last edited by

      UIKit gestures wrapper has been updated with support for fine-tuning recognition when several gestures are involved. Thanks to @JonB for all the difficult bits of code.

      Here's the updated section from the readme:

      Fine-tuning gesture recognition

      If you need to control which gestures are recognized in which situation, you can override some methods.

      For example, by default only one gesture recognizer will be successful, but if you want to enable both zooming (pinch) and panning at the same time, allow both recognizers:

      g = Gestures()
      
      g.recognize_simultaneously = lambda gr, other_gr: gr == Gestures.PAN and other_gr == Gestures.PINCH
      

      The other methods you can override are fail and fail_other, corresponding to the other UIGestureRecognizerDelegate methods.

      All regular recognizers have convenience names that you can use like in the example above: TAP, PINCH, ROTATION, SWIPE, PAN, SCREEN_EDGE_PAN, LONG_PRESS.

      If you need to set these per gesture, instantiate separate Gestures objects.

      If you need even finer control and are not afraid to import objc_util, check the objc_*_default methods in the code.

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