Forum Archive

How to get a touch position?

Raymond

How to get the touch position on ui.View() ? Without using any library exept “ui” ?

cvp

@Raymond by subclassing ui.View.

See Examples/User Interface/Sketch.py

import ui
class MyView(ui.View):      
    def touch_began(self, touch):
        x,y = touch.location
        self.name = f'x={x} y={y}'
v = MyView()
v.background_color = 'white'
v.present('fullscreen')
cvp

@Raymond did my post answer to your question?

Raymond

Yes Yes Yes!!!! Thank you very much dude !!!