Exemplo n.º 1
0
BOOL LLUICtrl::focusPrevItem(BOOL text_fields_only)
{
	// this assumes that this method is called on the focus root.
	LLCtrlQuery query = getTabOrderQuery();
	if(text_fields_only || LLUI::sConfigGroup->getBOOL("TabToTextFieldsOnly"))
	{
		query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
	}
	viewList_t result = query(this);
	return focusPrev(result);
}
Exemplo n.º 2
0
BOOL LLUICtrl::focusPrevItem(BOOL text_fields_only)
{
	// this assumes that this method is called on the focus root.
	LLCtrlQuery query = getTabOrderQuery();
	static LLUICachedControl<bool> tab_to_text_fields_only ("TabToTextFieldsOnly", false);
	if(text_fields_only || tab_to_text_fields_only)
	{
		query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
	}
	child_list_t result = query(this);
	return focusPrev(result);
}
Exemplo n.º 3
0
void UI::onJoystickMotion (bool horizontal, int v)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onJoystickMotion(horizontal, v))
			return;
		if (window->isModal() || window->isFullscreen())
			break;
	}

	if (Config.getBindingsSpace() != BINDINGS_UI)
		return;

	if (_time - _lastJoystickMoveTime < 350 || horizontal) {
		_lastJoystickMovementValue = v;
		return;
	}

	// skip focus change if we go back to initial position
	if (v > 0 && v < _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	} else if (v < 0 && v > _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	}

	// now check whether our value is bigger than our movement delta
	const int delta = 2000;
	if (v < -delta) {
		focusPrev();
	} else if (v > delta) {
		focusNext();
	}

	_lastJoystickMoveTime = _time;
	_lastJoystickMovementValue = v;
}
Exemplo n.º 4
0
 void GuiContext::update(sf::RenderWindow &window) {
     sf::Vector2f mPos{ sf::Mouse::getPosition(window) };
     bool mDown = sf::Mouse::isButtonPressed(sf::Mouse::Button::Left);
     for(auto element : elements) {
         // cursor on element
         if(mPos.x > element->getPosition().x && mPos.x < element->getSize().x + element->getPosition().x && mPos.y > element->getPosition().y && mPos.y < element->getSize().y + element->getPosition().y){
             element->hovered_ = true;
             // mouse down
             if(mDown) {
                 element->mouseDown_ = true;
                 // this also sets the focus
                 for (auto focusElement : elements) {
                     focusElement->focussed_ = false;
                 }
                 element->focussed_ = true;
             }
             else {
                 // check if mouse was down before
                 if(element->mouseDown_) {
                     if(element->onClick_ != nullptr){
                         element->onClick_(*element, element->stateObj_);
                     }
                     // this also drags the focus to this element
                     for (auto focusElement : elements) {
                         focusElement->focussed_ = false;
                     }
                     element->focussed_ = true;
                 }
                 element->mouseDown_ = false;
             }
             
         }
         else {
             element->hovered_ = false;
             element->mouseDown_ = false;
         }
         element->update();
     }
     
     // return key
     if( sf::Keyboard::isKeyPressed(sf::Keyboard::Return) ) {
         if(!keyReturn_) {
             for(auto element : elements) {
                 if(element->focussed_ && element->onClick_ != nullptr){
                     element->onClick_(*element, element->stateObj_);
                 }
             }
             keyReturn_ = true;
         }
     }
     else {
         keyReturn_ = false;
     }
     
     // down key
     if( sf::Keyboard::isKeyPressed(sf::Keyboard::Down) ) {
         if(!keyDown_) {
             focusNext();
             keyDown_ = true;
         }
     }
     else {
         keyDown_ = false;
     }
     
     // up key
     if( sf::Keyboard::isKeyPressed(sf::Keyboard::Up) ) {
         if(!keyUp_) {
             focusPrev();
             keyUp_ = true;
         }
     }
     else {
         keyUp_ = false;
     }
 }