Ejemplo n.º 1
0
        private bool TryReselect(LeanSelectable selectable)
        {
            switch (reselect)
            {
            case ReselectType.KeepSelected:
            {
                if (Selectables.Contains(selectable) == false)                         // NOTE: Property
                {
                    return(true);
                }
            }
            break;

            case ReselectType.Deselect:
            {
                if (Selectables.Contains(selectable) == false)                         // NOTE: Property
                {
                    return(true);
                }
                else
                {
                    Deselect(selectable);
                }
            }
            break;

            case ReselectType.DeselectAndSelect:
            {
                if (Selectables.Contains(selectable) == true)                         // NOTE: Property
                {
                    Deselect(selectable);
                }
            }
                return(true);

            case ReselectType.SelectAgain:
            {
            }
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        protected bool TrySelect(LeanSelectable selectable)
        {
            if (selectable != null && selectable.isActiveAndEnabled == true)
            {
                if (TryReselect(selectable) == true)
                {
                    if (Selectables.Contains(selectable) == false)                     // NOTE: Property
                    {
                        switch (limit)
                        {
                        case LimitType.Unlimited:
                        {
                        }
                        break;

                        case LimitType.StopAtMax:
                        {
                            if (selectables.Count >= maxSelectables)
                            {
                                return(false);
                            }
                        }
                        break;

                        case LimitType.DeselectFirst:
                        {
                            if (selectables.Count > 0 && selectables.Count >= maxSelectables)
                            {
                                TryDeselect(selectables[0]);
                            }
                        }
                        break;
                        }
                    }

                    selectables.Add(selectable);

                    if (onSelected != null)
                    {
                        onSelected.Invoke(selectable);
                    }

                    if (OnAnySelected != null)
                    {
                        OnAnySelected.Invoke(this, selectable);
                    }

                    selectable.InvokeOnSelected(this);

                    return(true);
                }
            }
            // Nothing was selected?
            else
            {
                if (onNothing != null)
                {
                    onNothing.Invoke();
                }

                if (deselectWithNothing == true)
                {
                    DeselectAll();
                }
            }

            return(false);
        }