Exemplo n.º 1
0
 private void ControllerOnMoveToElement(UiElement uiElement)
 {
     if (CurrentElement != uiElement)
     {
         CurrentElement?.Unfocus();
         CurrentElement = uiElement;
         CurrentElement.Focus();
     }
 }
Exemplo n.º 2
0
        private void ControllerOnMoveToPreviousElement()
        {
            var lastElement = CurrentElement;

            if (CurrentElement == null)
            {
                CurrentElement = _interactableElements.FirstOrDefault();
            }
            else
            {
                var index = _interactableElements.IndexOf(CurrentElement);
                CurrentElement = index == 0 ? _interactableElements[_interactableElements.Count - 1] : _interactableElements[index - 1];
            }

            if (lastElement != CurrentElement)
            {
                lastElement?.Unfocus();
                CurrentElement?.Focus();
            }
        }
Exemplo n.º 3
0
        public virtual void Update(GameTime gameTime)
        {
            if (_rearrangeList)
            {
                _interactableElements.RemoveAll(e => !e.IsInteractable);
                _interactableElements.Sort((e1, e2) => e1.TabIndex.CompareTo(e2.TabIndex));
            }

            foreach (var inputController in InputControllers)
            {
                inputController.Update(this);
            }

            if (_elementToGetFocus != null && _elementToGetFocus.State == UiState.Active)
            {
                _elementToGetFocus.Focus();
                CurrentElement     = _elementToGetFocus;
                _elementToGetFocus = null;
            }
        }