You should be able to use pygame.mouse.get_pressed() to find out if the mouse button is currently pressed and if the mouse is currently on top of your rectangle.