The default behavior for most widgets is to allow touch events to continue to be dispatched. This is controlled by the return value of the on_touch_XXX()
methods. A True
return means "do not continue dispatching" and a False
return means "continue dispatching". So you can halt the dispatch of on_touch_down
events by defining a custom class that stops the dispatching. For example:
class MyTouchBlocker(RelativeLayout):
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
return True
else:
return super(MyTouchBlocker, self).on_touch_down(touch)
And in your code, you can replace:
layout = RelativeLayout()
with:
layout = MyTouchBlocker()
See the documentation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…