Forum Archive

Interacting with UITouches

filippocld

Hi all,
I was thinking UITouches and some cool things i can do with them. The problem is i don't know how to detect a touch ( in real objc i used touchesBegan but i dont think it is possible in pythonista).
Is there another way to detect touches?
Thanks in Advance,
Filippo

Webmaster4o

Pretty sure @ProfSpaceCadet did this in his screen recorder.

filippocld

True, more or less it is what i need. Any other way?

Webmaster4o

@filippocld Why doesn't his method work?

filippocld

It works, but i was looking for more and simpler solutions. If this is the only way it's good :-)

omz

I think you'd have to be a bit more specific about what you're actually trying to achieve...

omz

Perhaps worth noting: ui.Touch can be "bridged" to ObjC, e.g. you could get access to a UITouch instance like this:

import ui
from objc_util import ObjCInstance

class MyView (ui.View):
    def touch_began(self, touch):
        ui_touch = ObjCInstance(touch)
        print(ui_touch)

MyView().present('sheet')
filippocld

Thanks, i didn't think about ui. The @ProfSpaceCadet example was goot but was a bit overkill for now.Currently I am experimenting with the ui method. :-)