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?
-
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 thetouch_*
methods, useObjCInstance
on thetouch
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
, thetouch
argument to the methods is not compatible withObjCInstance
. 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 aScene
? -
@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.