void GUICheckBox::checkMouseEvents(MouseEvent &newEvent, int extraInfo, bool bits)
{
  GUIRectangle::checkMouseEvents(newEvent, extraInfo, true);
  GUIEventListener *eventsListener = getEventsListener();
  
  if (clicked)
  {
    setChecked(!checked);
    if (eventsListener)
      eventsListener->actionPerformed(GUIEvent(this));
  }
  released = false;
  clicked  = false;
}
void GUIRectangle::checkMouseEvents(MouseEvent &newEvent, int extraInfo, bool bits)
{
  GUIEventListener *eventsListener = getEventsListener();
  bool              nRelease = pressed;

  mouseOver  = (newEvent.getY() >= windowBounds.y) &&
               (newEvent.getY() <= windowBounds.w) &&
               (newEvent.getX() >= windowBounds.x) &&
               (newEvent.getX() <= windowBounds.z);


  if(!mouseOver)
  {
    pressed = (extraInfo == RELEASED) ? false : pressed;
    if(extraInfo == PRESSED || extraInfo == RELEASED)  focused = false;
    return;
  }

  if(extraInfo == RELEASED && (lastAction == CLICKED || pressed))
  {
    clicked = true;
    pressed = false;
  }

  if(clicked) 
    focused = true;

  if(extraInfo == CLICKED)
    pressed = true;

  lastAction = extraInfo;
  released   = !pressed && nRelease;

  if(eventsListener && eventDetected()){
    GUIEvent event = GUIEvent(this);
    eventsListener->actionPerformed(event);
  }

  if(!bits)
  {
    released = false;
    clicked  = false;
  }
}