Skip to content

Dragable Widget

Mathieu Virbel edited this page Sep 27, 2013 · 1 revision
#!Python
class DragableObject( Widget ):
    def on_touch_down( self, touch ):
        if self.collide_point( *touch.pos ):
            touch.grab( self )
            return True
    
    def on_touch_up( self, touch ):
        if touch.grab_current is self:
            touch.ungrab( self )
            return True
    
    def on_touch_move( self, touch ):
        if touch.grab_current is self:
            self.pos = touch.x-self.width/2, touch.y-self.height/2
Clone this wiki locally