title: Pygame - How do I check if my rect has already been clicked?
body: <p>What I'm trying to do is if a rect has been clicked, it is selected and text will display, but if its clicked again, then it is de-seleced and the text goes away.</p>
  
  <p>list_of_rect is a list of coordinates (x, y, width, height) representing the position and size of the rect.</p>
  
  <p>render_display just shows the screen with text.</p>
  
  <pre><code>if event.type == pygame.MOUSEBUTTONUP and event.button == 1:
      x, y = event.pos
      for i in range(len(list_of_rect)):
          j = list_of_rect[i]
          if j[0][0] &lt;= x &lt;= (j[0][0] + j[0][2]) and j[0][1] &lt;= y &lt;= \
                  (j[0][1] + j[0][3]):
                  render_display(screen, text)
  </code></pre>
  
  <p><strong>EDIT</strong>: One idea I was thinking was to keep track of the rectangle that has been clicked on. But I'm not sure how to implement this</p>