Exemple #1
0
bool Slider::relayEvents(sf::Event const &event, sf::Input const &input) {
    if (WidgetBase::relayEvents(event, input)) { // evenement capture : traitement
	if (input.IsMouseButtonDown(sf::Mouse::Left)) {
	    // on doit deplacer le curseur en consequence et modifier la valeur du slider
	    float px = input.GetMouseX();
	    float d = _max - _min;
	    float w = _frame.getWidth() / d;
	    int value = (px - _frame.getPX() + w/2) / w + _min; // valeur pointee par le curseur
	    setValue(value);

            // notification
            if (_pListener)
                _pListener->notifyChangedValue(*this);
	}
	return true;
    }

    return false;
}
Exemple #2
0
void GUIPage::HandleInput(const sf::Input& input) {
  int x = input.GetMouseX();
  int y = input.GetMouseY();

  focusedElement = NULL;

  // TODO: This loop is also repeated in GUIPage::Click().
  // bring it out into a separate method.
  for(unsigned int i = 0; i < elements.size(); ++i) {
    if(elements[i]->shape.Contains(x, y)) {
      elements[i]->focused = true;

      focusedElement = elements[i];
      break;
    } else {
      elements[i]->focused = false;
    }
  }
  
}