internal void SelectionChange(EQEQEvent e) { toggles[_selected].SetVal(false); Toggle2D toggle = (Toggle2D) e.value; _selected = toggle.id; DispatchEvent(new EQEQEvent(EQEQEvent.CHANGED, this)); }
/** Dispatches a new event object. If this object has any recorded listeners, those handler functions will be called. */ public void DispatchEvent(EQEQEvent e) { if(_eventListeners[e.type] == null) return; for(int i = 0; i < (_eventListeners[e.type] as ArrayList).Count; i++) { EQEQEvent.EventHandler handler = (EQEQEvent.EventHandler) (_eventListeners[e.type] as ArrayList)[i]; handler(e); } }
/** Adds a delegate function (EQEQEvent.EventHandler handler) which will be called whenever this object dispatches the event (string type). */ public virtual void AddEventListener(string type, EQEQEvent.EventHandler handler) { if(!_eventListeners.Contains(type)) { _eventListeners.Add(type, new ArrayList()); (_eventListeners[type] as ArrayList).Add(handler); } else { (_eventListeners[type] as ArrayList).Add(handler); } }
/** Removes the specified event listener. */ public virtual void RemoveEventListener(string type, EQEQEvent.EventHandler handler) { (_eventListeners[type] as ArrayList).Remove(handler); }