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.


    Getting at ObjC touch instance from Scene?

    Pythonista
    pencil touch scene
    2
    2
    1123
    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.
    • trey
      trey last edited by trey

      I have a Scene-based program where I’d like to distinguish between finger and Pencil touch events.

      An example from omz showed how to do this in a ui.View; in the touch_* methods, use ObjCInstance on the touch argument:

          def touch_moved(self, touch):
              ui_touch = ObjCInstance(touch)
      

      then, I have verified, you can check the value of ui_touch.type() to determine if the touch is from a finger (0) or a Pencil (2).

      Unfortunately, I found out if you attempt to do the same in a Scene, the touch argument to the methods is not compatible with ObjCInstance. You get:

      ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
      

      so, I’m wondering how I can get at a Touch object I can use the ObjC bridge with via a Scene?

      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @trey last edited by

        @trey, one idea would be to place a transparent view on top (as a subview of scene.view) to handle the touches.

        Then you would need to check if the touch is near the top-right corner to simulate clicking on the ”x” with superview.close(). And remember to flip the y coordinate before passing the coordinate and touch type to your scene code. And maybe go via screen coordinates if you do a lot of zooming and panning in your scene.

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