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开始 } } }
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)); } }
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_); }