OOP Workshop
Check Button Clicks
def anyShapeSelected(x,y):
global selectedButton
for i in range(len(shapeButtons)):
shapeB = shapeButtons[i]
if(shapeB.isClicked(x,y)):
print(shapeB.buttonShape, "was clicked")
if(shapeB is selectedButton):
return False
selectedButton = shapeB
return True
return False
Whenever the pointer clicks on the display, all buttons are checked for the given pair of coordinates to decide whether the selected button has changed.