Ejemplo n.º 1
0
        private bool HandleControlsInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            MyGuiControlBase inputHandledBySomeControl = null;

            if (m_lastHandlingControl != null && m_lastHandlingControl.Visible)
            {
                if (m_lastHandlingControl.HandleInput(input, m_controlsAll.IndexOf(m_lastHandlingControl) == m_keyboardControlIndex, m_controlsAll.IndexOf(m_lastHandlingControl) == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true)
                {
                    inputHandledBySomeControl = m_lastHandlingControl;
                }
            }

            if (inputHandledBySomeControl == null && m_listboxDragAndDropHandlingNow != null)
            {
                if (m_listboxDragAndDropHandlingNow.HandleInput(input, m_controlsAll.IndexOf(m_listboxDragAndDropHandlingNow) == m_keyboardControlIndex, m_controlsAll.IndexOf(m_listboxDragAndDropHandlingNow) == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true)
                {
                    inputHandledBySomeControl = m_listboxDragAndDropHandlingNow;
                }
            }

            if (inputHandledBySomeControl == null && m_comboboxHandlingNow != null)
            {
                if (m_comboboxHandlingNow.HandleInput(input, m_controlsAll.IndexOf(m_comboboxHandlingNow) == m_keyboardControlIndex, m_controlsAll.IndexOf(m_comboboxHandlingNow) == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true)
                {
                    inputHandledBySomeControl = m_comboboxHandlingNow;
                }
            }

            //  If opened combobox didn't capture the input, we will try to handle it in remaining controls
            if (inputHandledBySomeControl == null)
            {
                for (int i = 0; i < m_controlsAll.Count; i++)
                {
                    MyGuiControlBase control = m_controlsAll[i];
                    if (control != m_comboboxHandlingNow && control != m_listboxDragAndDropHandlingNow && control.Visible)
                    {
                        if (control.HandleInput(input, i == m_keyboardControlIndex, i == m_keyboardControlIndexPrevious, receivedFocusInThisUpdate) == true)
                        {
                            inputHandledBySomeControl = control;
                            break;
                        }
                    }
                }
            }

            m_keyboardControlIndexPrevious = m_keyboardControlIndex;

            if (inputHandledBySomeControl != null)
            {
                m_keyboardControlIndex         = m_controlsAll.IndexOf(inputHandledBySomeControl);
                m_keyboardControlIndexPrevious = m_keyboardControlIndex;    //  We need to reset it, otherwise we will hear two mouseover sounds!!!
            }

            m_lastHandlingControl = inputHandledBySomeControl;

            return(inputHandledBySomeControl != null);
        }