Exemple #1
0
        public static bool SetFocus(MaterialFocusGroup p_container)
        {
            MaterialFocusGroup v_oldFocus = GetFocus();

            if (p_container != null)
            {
                if (v_oldFocus != p_container)
                {
                    var v_index = FocusOrder.IndexOf(p_container);
                    if (v_index >= 0)
                    {
                        FocusOrder.RemoveAt(v_index);
                    }

                    if (FocusOrder.Count > 0)
                    {
                        FocusOrder.Insert(0, p_container);
                    }
                    else
                    {
                        FocusOrder.Add(p_container);
                    }
                    //Call Focus Events
                    if (v_oldFocus != null)
                    {
                        v_oldFocus.HandleOnLoseFocus();
                    }

                    p_container.HandleOnGainFocus();

                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        public static bool RemoveFocus(MaterialFocusGroup p_container, bool p_keepInList)
        {
            if (p_container != null)
            {
                if (!p_container.enabled)
                {
                    p_keepInList = false;
                }
                MaterialFocusGroup v_oldFocus = GetFocus();
                var v_index = FocusOrder.IndexOf(p_container);
                if (v_index >= 0)
                {
                    FocusOrder.RemoveAt(v_index);
                }
                if (p_keepInList)
                {
                    FocusOrder.Add(p_container);
                    var v_newIndex = FocusOrder.IndexOf(p_container);
                    //Focus cant change because we have only one object in list
                    if (v_newIndex == v_index)
                    {
                        return(false);
                    }
                }
                //Call Focus Events
                if (v_oldFocus == p_container)
                {
                    MaterialFocusGroup v_newFocus = GetFocus();
                    if (v_oldFocus != null)
                    {
                        v_oldFocus.HandleOnLoseFocus();
                    }

                    if (v_newFocus != null)
                    {
                        v_newFocus.HandleOnGainFocus();
                    }

                    return(true);
                }
                else if (v_oldFocus != null)
                {
                    v_oldFocus.StartKeyTriggerUpdateRoutine();
                }
            }
            return(false);
        }