yoyo
Jul 03, 2018 - 04:11
I would like you to check my sample code for touch_began() method.
Thanks to your support, I understood how to set touch_began() to a pyui file.
Although I could set a method to a whole UI. I would like to set touch_began() to a specifed object like a button on the UI. Could you please tell me how?
My sample code is following.
In pyui file, I set “MyView” to Custom View Class via design tool. As a result, when I touched somewhere on the screen, “touch”, “move” and “end” messages were displayed in a console.
I would like to set a method to supecified button. Do I need to set something to CUSTOM ATTRIBUTES for a object?
import ui
class MyView (ui.View):
def touch_began(self, touch):
# Called when a touch begins.
print('touch')
def touch_moved(self, touch):
# Called when a touch moves.
print('move')
def touch_ended(self, touch):
# Called when a touch ends.
print('end')
v2= ui.load_view('touch_sample')
v2.present('sheet')