Beispiel #1
0
        void OnToggleValueChanged(KToggle target_, bool isOn_)
        {
            int lastIndex = m_lastIndex;

            if (isOn_)
            {
                if (!m_allowMultiple)
                {
                    //不允许多选,取消上一个
                    if (m_lastIndex >= 0)
                    {
                        KToggle last = m_toggleList[m_lastIndex];
                        last.Select(false, true);
                        RemoveFromSelect(m_lastIndex);
                        m_lastIndex = -1;
                    }
                }

                m_lastIndex = m_toggleList.IndexOf(target_);
                m_selectList.Add(m_lastIndex);

                if (!m_ingoreInvoke)
                {
                    onValueChange.Invoke(this, m_lastIndex, isOn_);
                    LuaEvtCenter.AddGoEvent(gameObject, KUI_EVT.VALUE_CHANGE, m_lastIndex + 1, isOn_);     //lua从1开始
                }
            }
            else
            {
                //取消
                int index = m_toggleList.IndexOf(target_);
                RemoveFromSelect(index);

                if (m_lastIndex == index)
                {
                    m_lastIndex = -1;
                }

                if (m_allowMultiple)
                {
                    if (m_selectList.Count > 0)
                    {
                        //多选,还有选中的
                        m_lastIndex = m_selectList[m_selectList.Count - 1];
                    }
                }

                if (!m_ingoreInvoke)
                {
                    onValueChange.Invoke(this, index, isOn_);
                    LuaEvtCenter.AddGoEvent(gameObject, KUI_EVT.VALUE_CHANGE, index + 1, isOn_);   //lua从1开始
                }
            }
        }
Beispiel #2
0
 static public int get_needReqChange(IntPtr l)
 {
     try {
         mg.org.KUI.KToggle self = (mg.org.KUI.KToggle)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.needReqChange);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #3
0
        /// <summary>
        /// 根据序号选中
        /// </summary>
        /// <param name="index"></param>
        /// <param name="b_"></param>
        /// <param name="ingoreInvoke_">不派事件</param>
        public void Select(int index, bool b_, bool ingoreInvoke_ = false)
        {
            KToggle toggle = m_toggleList[index];

            if (toggle.isOn == b_)
            {
                return;
            }

            m_ingoreInvoke = ingoreInvoke_;
            toggle.isOn    = b_;
            m_ingoreInvoke = false;
        }
Beispiel #4
0
 static public int set_needReqChange(IntPtr l)
 {
     try {
         mg.org.KUI.KToggle self = (mg.org.KUI.KToggle)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.needReqChange = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #5
0
 static public int Select(IntPtr l)
 {
     try {
         mg.org.KUI.KToggle self = (mg.org.KUI.KToggle)checkSelf(l);
         System.Boolean     a1;
         checkType(l, 2, out a1);
         System.Boolean a2;
         checkType(l, 3, out a2);
         self.Select(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #6
0
        void OnToggleReqChanged(KToggle target_, bool isOn_)
        {
            if (m_needReqChange)
            {
                int index = m_toggleList.IndexOf(target_);

                onReqChange.Invoke(this, index, isOn_);
                LuaEvtCenter.AddGoEvent(gameObject, KUI_EVT.REQ_VALUE_CHANGE, index + 1, isOn_);  //lua从1开始
                return;
            }

            if (!m_allowSwitchOff && !m_allowMultiple)
            {
                //不允许取消 and 不为多选
                if (isOn_ == false)
                {
                    return;
                }
            }

            target_.Select(isOn_);
        }
Beispiel #7
0
        /// <summary>
        /// 指定序号是否选中
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool isSelected(int index = 0)
        {
            KToggle toggle = m_toggleList[index];

            return(toggle.isOn);
        }