OOP Workshop

Button Select Method

def isClicked(self, x, y):        
        return self.buttonX < x < self.buttonX + self.width and \
		 self.buttonY < y < self.buttonY + self.height

In order to identify whether a certain button has been clicked on the screen, the coordinates of the pointer can be compared to the rectangular boundaries of the button. This function can be overridden for checking against the exact boundaries of a circular button or a triangular button, etc.