FairyGUI.EventDispatcher.AddEventListener C# (CSharp) Method

AddEventListener() public method

public AddEventListener ( string strType, EventCallback0 callback ) : void
strType string
callback EventCallback0
return void
        public void AddEventListener(string strType, EventCallback0 callback)
        {
            if (strType == null)
                throw new Exception("event type cant be null");

            if (_dic == null)
                _dic = new Dictionary<string, EventBridge>();

            EventBridge bridge = null;
            if (!_dic.TryGetValue(strType, out bridge))
            {
                bridge = new EventBridge(this);
                _dic[strType] = bridge;
            }
            bridge.Add(callback);
        }

Same methods

EventDispatcher::AddEventListener ( string strType, EventCallback1 callback ) : void

Usage Example

 static public int AddEventListener(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(string), typeof(FairyGUI.EventCallback1)))
         {
             FairyGUI.EventDispatcher self = (FairyGUI.EventDispatcher)checkSelf(l);
             System.String            a1;
             checkType(l, 2, out a1);
             FairyGUI.EventCallback1 a2;
             LuaDelegation.checkDelegate(l, 3, out a2);
             self.AddEventListener(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(FairyGUI.EventCallback0)))
         {
             FairyGUI.EventDispatcher self = (FairyGUI.EventDispatcher)checkSelf(l);
             System.String            a1;
             checkType(l, 2, out a1);
             FairyGUI.EventCallback0 a2;
             LuaDelegation.checkDelegate(l, 3, out a2);
             self.AddEventListener(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
All Usage Examples Of FairyGUI.EventDispatcher::AddEventListener