onMouseButtonUp, onMouseButtonDown()

Methods that are called when a mouse button is pressed or released, respectively. These event handler methods are fired in the world, in sprites and in tags. In sprites and tags they are only fired when the mouse pointer is actually over the content of this element (over what is drawn in the element's onDraw()) while being clicked. Events for sprites and tags have to be enabled when needed by calling enableMouseEvents() on the element.

class Atlantis(World):
    def onMouseButtonUp(self, event):
    	pass
    def onMouseButtonDown(self, event):
    	pass
class ASprite(Sprite):
    def onMouseButtonUp(self, event):
    	pass
    def onMouseButtonDown(self, event):
    	pass
class ATag(Tag):
    def onMouseButtonUp(self, event):
    	pass
    def onMouseButtonDown(self, event):
    	pass

Relevant examples: tag_drag.py , mouse.py , ALL

In Context

class Atlantis(World):
    def onSetup(self):
        d = Disc(self, 'tag1')
        d.enableMouseEvents()

    def onMouseButtonUp(self, event):
        print 'Mouse has been clicked.'
        if glo.ia.LMB:
   	        print 'Left button has been clicked.'
    	if glo.ia.MMB:
    	    print 'Middle button has been clicked.'
    	if glo.ia.RMB:
    	    print 'Right button has been clicked.'
    	
class Disc(Tag):
    def onDraw(self):
        disc(200, 200, 100)
        
    def onMouseButtonUp(self, event):
    	print '-> Disc has been clicked.'
Initiated by Stephan Hechenberger
Thanks to CADRE's 103