예제 #1
0
        public void OnKeyboardEvent(KeyboardEvent keyboardevent)
        {
            if (keyboardevent.Tab)
            {
                var tabIndexElements = new List <Element2D>();
                m_oframeRootMasterElement.GetNextTabIndexElement(ref tabIndexElements);
                var num1 = -1;
                foreach (Element2D element2D in tabIndexElements)
                {
                    if (element2D.tabIndex > num1)
                    {
                        num1 = element2D.tabIndex;
                    }
                }
                var num2       = -1;
                var element2D1 = (Element2D)null;
                if (m_oeFocusElement != null)
                {
                    element2D1 = m_oeFocusElement;
                    num2       = m_oeFocusElement.tabIndex;
                }
                var num3 = -1;
                foreach (Element2D element2D2 in tabIndexElements)
                {
                    if (element2D2.tabIndex != num2)
                    {
                        if (element2D2.tabIndex < num2)
                        {
                            if (num1 - num2 + element2D2.tabIndex < num3 || num3 == -1)
                            {
                                m_oeFocusElement = element2D2;
                                num3             = num1 - num2 + element2D2.tabIndex;
                            }
                        }
                        else if (element2D2.tabIndex - num2 < num3 || num3 == -1)
                        {
                            m_oeFocusElement = element2D2;
                            num3             = element2D2.tabIndex - num2;
                        }
                    }
                }
                if (element2D1 != null)
                {
                    element2D1.HasFocus = false;
                }

                if (m_ocbComboboxSelected != null)
                {
                    m_ocbComboboxSelected.ShowDropDown = false;
                }

                m_oeFocusElement.HasFocus = true;
                if (m_oeFocusElement.GetElementType() == ElementType.ComboBoxWidget)
                {
                    m_ocbComboboxSelected = (ComboBoxWidget)m_oeFocusElement;
                }
                else
                {
                    m_ocbComboboxSelected = null;
                }
            }
            else if (keyboardevent.Type == KeyboardEventType.CommandKey && ((CommandKeyEvent)keyboardevent).Key == KeyboardCommandKey.Escape)
            {
                m_oframeRootMasterElement.OnKeyboardEvent(keyboardevent);
            }
            else if (m_oeFocusElement != null)
            {
                if (m_ocbComboboxSelected != null)
                {
                    m_ocbComboboxSelected.OnKeyboardEvent(keyboardevent);
                }
                else if (m_oeFocusElement.IsListBoxElement())
                {
                    ListBoxWidget listBoxElement = m_oeFocusElement.GetListBoxElement();
                    if (listBoxElement == null)
                    {
                        return;
                    }

                    listBoxElement.HasFocus = true;
                    listBoxElement.OnKeyboardEvent(keyboardevent);
                    listBoxElement.HasFocus = false;
                }
                else
                {
                    m_oeFocusElement.OnKeyboardEvent(keyboardevent);
                }
            }
            else
            {
                m_oframeRootMasterElement.OnKeyboardEvent(keyboardevent);
            }
        }
예제 #2
0
        public bool OnMouseCommand(MouseEvent mouseevent)
        {
            var flag = false;

            if (mouseevent.type == MouseEventType.Leave)
            {
                m_oframeRootMasterElement.OnMouseLeave();
                return(false);
            }
            tooltipFrame.Hide();
            m_oeMouseOverElement = m_oframeRootControlElement.GetSelfOrDependantAtPoint(mouseevent.pos.x, mouseevent.pos.y);
            if (m_oeMouseOverElement == null)
            {
                if (m_oeFocusElement != null && m_oeFocusElement.Visible && m_oeFocusElement.Enabled)
                {
                    m_oeMouseOverElement = m_oeFocusElement.GetSelfOrDependantAtPoint(mouseevent.pos.x, mouseevent.pos.y);
                }

                if (m_oeMouseOverElement == null)
                {
                    m_oeMouseOverElement = m_oframeRootMasterElement.GetSelfOrDependantAtPoint(mouseevent.pos.x, mouseevent.pos.y);
                }
            }
            if (m_oeSelectedElement != null && m_oeSelectedElement != m_oeMouseOverElement)
            {
                flag = m_oeSelectedElement.OnMouseCommand(mouseevent);
                m_oeSelectedElement = null;
            }
            Element2D mouseOverElement = m_oeMouseOverElement;

            if (mouseOverElement != null)
            {
                m_oeSelectedElement = mouseOverElement;
                flag = mouseOverElement.OnMouseCommand(mouseevent);
                if (mouseOverElement.GetElementType() != ElementType.Frame && mouseOverElement.GetElementType() != ElementType.ScrollFrame)
                {
                    if (mouseevent.type == MouseEventType.Down)
                    {
                        if (m_oeSelectedElement.IsComboBoxElement())
                        {
                            if (m_ocbComboboxSelected != null && m_ocbComboboxSelected != m_oeSelectedElement.GetComboBoxElement())
                            {
                                m_ocbComboboxSelected.ShowDropDown = false;
                                m_ocbComboboxSelected.HasFocus     = false;
                            }
                            m_ocbComboboxSelected = m_oeSelectedElement.GetComboBoxElement();
                        }
                        else if (m_ocbComboboxSelected != null)
                        {
                            m_ocbComboboxSelected.ShowDropDown = false;
                            m_ocbComboboxSelected = null;
                        }
                        if (m_oeFocusElement != null && m_oeFocusElement != mouseOverElement && m_oeFocusElement != m_ocbComboboxSelected)
                        {
                            m_oeFocusElement.HasFocus = false;
                        }

                        m_oeFocusElement          = mouseOverElement;
                        m_oeFocusElement.HasFocus = true;
                        if (m_ocbComboboxSelected != null)
                        {
                            m_ocbComboboxSelected.HasFocus = true;
                        }
                    }
                    else if (mouseevent.type == MouseEventType.Up && mouseevent.button == MouseButton.Right)
                    {
                        var elementType = (int)m_oeMouseOverElement.GetElementType();
                    }
                }
                if (mouseevent.type == MouseEventType.MouseWheel)
                {
                    if (m_oeSelectedElement.IsListBoxElement())
                    {
                        ListBoxWidget listBoxElement = m_oeSelectedElement.GetListBoxElement();
                        if (listBoxElement != null)
                        {
                            if (mouseevent.delta > 0)
                            {
                                listBoxElement.ScrollBar.MoveSlider(-1f);
                            }
                            else
                            {
                                listBoxElement.ScrollBar.MoveSlider(1f);
                            }
                        }
                    }
                    else if (m_oeSelectedElement.IsScrollFrame())
                    {
                        m_oeSelectedElement.GetScrollFrame()?.OnMouseCommand(mouseevent);
                    }
                }
            }
            else if (GlobalChildDialog.Count > 0 && mouseevent.type == MouseEventType.Down)
            {
                Element2D element2D = GlobalChildDialog.Last();
                if (element2D is Frame)
                {
                    ((Frame)element2D).Close();
                }
            }
            if (mouseevent.type == MouseEventType.Up)
            {
                m_oframeRootMasterElement.OnMouseLeave();
                if (m_ocbComboboxSelected != null && m_oeSelectedElement == null)
                {
                    m_ocbComboboxSelected.ShowDropDown = false;
                }
            }
            m_oframeRootMasterElement.OnMouseMove(mouseevent.pos.x, mouseevent.pos.y);
            m_smePrevMouseEvent = mouseevent;
            return(flag);
        }