Ejemplo n.º 1
0
    public void AddEndDragListener(string compName, InputEventHandle <InputUIOnEndDragEvent> callback, string parm = null)
    {
        InputEventRegisterInfo <InputUIOnEndDragEvent> info = InputUIEventProxy.GetOnEndDragListener(GetDragComp(compName), UIEventKey, compName, parm, callback);

        info.AddListener();
        m_EndDragEvents.Add(info);
    }
Ejemplo n.º 2
0
    public void RemoveLongPressListener(string compName, InputEventHandle <InputUILongPressEvent> callback, string parm = null)
    {
        InputEventRegisterInfo <InputUILongPressEvent> info = GetLongPressRegisterInfo(compName, callback, parm);

        m_LongPressEvents.Remove(info);
        info.RemoveListener();
    }
Ejemplo n.º 3
0
    public void AddOnClickListenerByCreate(Button button, string compName, InputEventHandle <InputUIOnClickEvent> callback, string parm = null)
    {
        InputButtonClickRegisterInfo info = InputUIEventProxy.GetOnClickListener(button, UIEventKey, compName, parm, callback);

        info.AddListener();
        m_OnClickEvents.Add(info);
    }
Ejemplo n.º 4
0
    static int RemoveListener(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 3);
            string arg0 = ToLua.CheckString(L, 1);
            string arg1 = ToLua.CheckString(L, 2);
            InputEventHandle <IInputEventBase> arg2 = null;
            LuaTypes funcType3 = LuaDLL.lua_type(L, 3);

            if (funcType3 != LuaTypes.LUA_TFUNCTION)
            {
                arg2 = (InputEventHandle <IInputEventBase>)ToLua.CheckObject(L, 3, typeof(InputEventHandle <IInputEventBase>));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 3);
                arg2 = DelegateFactory.CreateDelegate(typeof(InputEventHandle <IInputEventBase>), func) as InputEventHandle <IInputEventBase>;
            }

            InputManager.RemoveListener(arg0, arg1, arg2);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 public void RemoveListener(string eventKey, InputEventHandle <Event> callBack)
 {
     if (m_Listeners.ContainsKey(eventKey))
     {
         m_Listeners[eventKey] -= callBack;
     }
 }
Ejemplo n.º 6
0
    static int AddOnClickListenerByCreate(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 5);
            UIBase obj = (UIBase)ToLua.CheckObject(L, 1, typeof(UIBase));
            UnityEngine.UI.Button arg0 = (UnityEngine.UI.Button)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.UI.Button));
            string arg1 = ToLua.CheckString(L, 3);
            InputEventHandle <InputUIOnClickEvent> arg2 = null;
            LuaTypes funcType4 = LuaDLL.lua_type(L, 4);

            if (funcType4 != LuaTypes.LUA_TFUNCTION)
            {
                arg2 = (InputEventHandle <InputUIOnClickEvent>)ToLua.CheckObject(L, 4, typeof(InputEventHandle <InputUIOnClickEvent>));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 4);
                arg2 = DelegateFactory.CreateDelegate(typeof(InputEventHandle <InputUIOnClickEvent>), func) as InputEventHandle <InputUIOnClickEvent>;
            }

            string arg3 = ToLua.CheckString(L, 5);
            obj.AddOnClickListenerByCreate(arg0, arg1, arg2, arg3);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 7
0
    public void RemoveOnClickListener(string buttonName, InputEventHandle <InputUIOnClickEvent> callback, string parm = null)
    {
        InputButtonClickRegisterInfo info = GetClickRegisterInfo(buttonName, callback, parm);

        m_OnClickEvents.Remove(info);
        info.RemoveListener();
    }
Ejemplo n.º 8
0
    static int AddLongPressListener(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 4);
            UIBase obj  = (UIBase)ToLua.CheckObject(L, 1, typeof(UIBase));
            string arg0 = ToLua.CheckString(L, 2);
            InputEventHandle <InputUILongPressEvent> arg1 = null;
            LuaTypes funcType3 = LuaDLL.lua_type(L, 3);

            if (funcType3 != LuaTypes.LUA_TFUNCTION)
            {
                arg1 = (InputEventHandle <InputUILongPressEvent>)ToLua.CheckObject(L, 3, typeof(InputEventHandle <InputUILongPressEvent>));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 3);
                arg1 = DelegateFactory.CreateDelegate(typeof(InputEventHandle <InputUILongPressEvent>), func) as InputEventHandle <InputUILongPressEvent>;
            }

            string arg2 = ToLua.CheckString(L, 4);
            obj.AddLongPressListener(arg0, arg1, arg2);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 9
0
    public void AddOnClickListener(string buttonName, InputEventHandle <InputUIOnClickEvent> callback, string parm = null)
    {
        InputButtonClickRegisterInfo info = InputUIEventProxy.GetOnClickListener(GetButton(buttonName), UIEventKey, buttonName, parm, callback);

        info.AddListener();
        m_OnClickEvents.Add(info);
    }
Ejemplo n.º 10
0
    public void AddLongPressListener(string compName, InputEventHandle <InputUILongPressEvent> callback, string parm = null)
    {
        InputEventRegisterInfo <InputUILongPressEvent> info = InputUIEventProxy.GetLongPressListener(GetLongPressComp(compName), UIEventKey, compName, parm, callback);

        info.AddListener();
        m_LongPressEvents.Add(info);
    }
Ejemplo n.º 11
0
    public static void AddAllEventListener <T>(InputEventHandle <T> callback) where T : IInputEventBase
    {
        string eventName = typeof(T).Name;

        InputDispatcher <T> dispatcher = GetDispatcher <T>();

        dispatcher.OnEventDispatch += callback;
    }
Ejemplo n.º 12
0
 public void RemoveListener(string eventKey, InputEventHandle <Event> callBack)
 {
     if (m_Listeners.ContainsKey(eventKey))
     {
         m_Listeners[eventKey] -= callBack;
     }
     //else
     //{
     //    Debug.LogError("不存在的UI事件 " + eventKey);
     //}
 }
Ejemplo n.º 13
0
 public void AddListener(string eventKey, InputEventHandle <Event> callBack)
 {
     if (!m_Listeners.ContainsKey(eventKey))
     {
         m_Listeners.Add(eventKey, callBack);
     }
     else
     {
         m_Listeners[eventKey] += callBack;
     }
 }
Ejemplo n.º 14
0
    public override void AddListener(string eventKey, InputEventHandle <IInputEventBase> callBack)
    {
        InputEventHandle <Event> temp = (inputEvent) =>
        {
            callBack((IInputEventBase)inputEvent);
        };

        m_ListenerHash.Add(callBack, temp);

        AddListener(eventKey, temp);
    }
Ejemplo n.º 15
0
    public override void RemoveListener(string eventKey, InputEventHandle <IInputEventBase> callBack)
    {
        if (!m_ListenerHash.ContainsKey(callBack))
        {
            throw new Exception("RemoveListener Exception: dont find Listener Hash ! eventKey: ->" + eventKey + "<-");
        }

        InputEventHandle <Event> temp = m_ListenerHash[callBack];

        m_ListenerHash.Remove(callBack);

        RemoveListener(eventKey, temp);
    }
Ejemplo n.º 16
0
 void DispatchSingleEvent(Event inputEvent, InputEventHandle <Event> callBack)
 {
     if (callBack != null)
     {
         try
         {
             callBack(inputEvent);
         }
         catch (Exception e)
         {
             Debug.LogError(e.ToString());
         }
     }
 }
Ejemplo n.º 17
0
 void DispatchSingleEvent(Event inputEvent, InputEventHandle <Event> callBack)
 {
     if (callBack != null)
     {
         try
         {
             callBack(inputEvent);
         }
         catch (Exception e)
         {
             Debug.LogError("DispatchSingleEvent Name: " + typeof(Event).ToString() + " key: " + inputEvent.EventKey + " Exception: " + e.ToString());
         }
     }
 }
Ejemplo n.º 18
0
    //TODO 逐步添加所有的移除监听方法

    public InputButtonClickRegisterInfo GetClickRegisterInfo(string buttonName, InputEventHandle <InputUIOnClickEvent> callback, string parm)
    {
        string eventKey = InputUIOnClickEvent.GetEventKey(UIEventKey, buttonName, parm);

        for (int i = 0; i < m_OnClickEvents.Count; i++)
        {
            InputButtonClickRegisterInfo info = (InputButtonClickRegisterInfo)m_OnClickEvents[i];
            if (info.eventKey == eventKey &&
                info.callBack == callback)
            {
                return(info);
            }
        }

        throw new Exception("GetClickRegisterInfo Exception not find RegisterInfo by " + buttonName + " parm " + parm);
    }
 void DispatchSingleEvent(Event inputEvent, InputEventHandle <Event> callBack)
 {
     if (callBack != null)
     {
         Delegate[] eventArray = callBack.GetInvocationList();
         for (int i = 0; i < eventArray.Length; i++)
         {
             try
             {
                 InputEventHandle <Event> tmp = (InputEventHandle <Event>)eventArray[i];
                 tmp(inputEvent);
             }
             catch (Exception e)
             {
                 Debug.LogError(e.ToString());
             }
         }
     }
 }
Ejemplo n.º 20
0
    public static Delegate InputEventHandle_InputUILongPressEvent(LuaFunction func, LuaTable self, bool flag)
    {
        if (func == null)
        {
            InputEventHandle <InputUILongPressEvent> fn = delegate(InputUILongPressEvent param0) { };
            return(fn);
        }

        if (!flag)
        {
            InputEventHandle_InputUILongPressEvent_Event target = new InputEventHandle_InputUILongPressEvent_Event(func);
            InputEventHandle <InputUILongPressEvent>     d      = target.Call;
            target.method = d.Method;
            return(d);
        }
        else
        {
            InputEventHandle_InputUILongPressEvent_Event target = new InputEventHandle_InputUILongPressEvent_Event(func, self);
            InputEventHandle <InputUILongPressEvent>     d      = target.CallWithSelf;
            target.method = d.Method;
            return(d);
        }
    }
Ejemplo n.º 21
0
 public abstract void AddListener(string eventKey, InputEventHandle<IInputEventBase> callBack);
Ejemplo n.º 22
0
 public abstract void RemoveListener(string eventKey, InputEventHandle <IInputEventBase> callBack);
Ejemplo n.º 23
0
    public static void RemoveListener(string eventName, string eventKey, InputEventHandle <IInputEventBase> callback)
    {
        IInputDispatcher dispatcher = GetDispatcher(eventName);

        dispatcher.RemoveListener(eventKey, callback);
    }
Ejemplo n.º 24
0
    public static void RemoveAllEventListener <T>(InputEventHandle <T> callback) where T : IInputEventBase
    {
        InputDispatcher <T> dispatcher = GetDispatcher <T>();

        dispatcher.OnEventDispatch -= callback;
    }
Ejemplo n.º 25
0
    public static void RemoveListener <T>(string eventKey, InputEventHandle <T> callback) where T : IInputEventBase
    {
        InputDispatcher <T> dispatcher = GetDispatcher <T>();

        dispatcher.RemoveListener(eventKey, callback);
    }
Ejemplo n.º 26
0
    public static void RemoveListener <T>(InputEventHandle <T> callback) where T : IInputEventBase
    {
        InputDispatcher <T> dispatcher = GetDispatcher <T>();

        dispatcher.RemoveListener(typeof(T).Name, callback);
    }
Ejemplo n.º 27
0
    public InputEventRegisterInfo <InputUILongPressEvent> GetLongPressRegisterInfo(string compName, InputEventHandle <InputUILongPressEvent> callback, string parm)
    {
        string eventKey = InputUILongPressEvent.GetEventKey(UIName, compName, parm);

        for (int i = 0; i < m_LongPressEvents.Count; i++)
        {
            InputEventRegisterInfo <InputUILongPressEvent> info = (InputEventRegisterInfo <InputUILongPressEvent>)m_LongPressEvents[i];
            if (info.eventKey == eventKey &&
                info.callBack == callback)
            {
                return(info);
            }
        }

        throw new Exception("GetLongPressRegisterInfo Exception not find RegisterInfo by " + compName + " parm " + parm);
    }
Ejemplo n.º 28
0
    public static InputEventRegisterInfo <InputUIOnScrollEvent> AddOnScrollListener(string UIName, string ComponentName, InputEventHandle <InputUIOnScrollEvent> callback)
    {
        InputEventRegisterInfo <InputUIOnScrollEvent> info = new InputEventRegisterInfo <InputUIOnScrollEvent>();

        info.eventKey = InputUIOnScrollEvent.GetEventKey(UIName, ComponentName);
        info.callBack = callback;

        InputManager.AddListener <InputUIOnScrollEvent>(
            InputUIOnScrollEvent.GetEventKey(UIName, ComponentName), callback);

        return(info);
    }
Ejemplo n.º 29
0
 public void AddOnClickListener(string buttonName, InputEventHandle<InputUIOnClickEvent> callback, string parm = null)
 {
     InputEventRegisterInfo<InputUIOnClickEvent> info = InputUIEventProxy.AddOnClickListener(GetButton(buttonName), UIEventKey, buttonName, parm, callback);
     m_OnClickEvents.Add(info);
 }
Ejemplo n.º 30
0
    public static InputEventRegisterInfo <InputUIOnClickEvent> AddOnClickListener(Button button, string UIName, string ComponentName, string parm, InputEventHandle <InputUIOnClickEvent> callback)
    {
        InputButtonClickRegisterInfo info = new InputButtonClickRegisterInfo();

        info.eventKey  = InputUIOnClickEvent.GetEventKey(UIName, ComponentName, parm);
        info.callBack  = callback;
        info.m_button  = button;
        info.m_OnClick = () =>
        {
            DispatchClickEvent(UIName, ComponentName, parm);
        };

        info.AddListener();

        button.onClick.AddListener(info.m_OnClick);

        return(info);
    }
    public static InputEventRegisterInfo <InputUILongPressEvent> AddLongPressListener(LongPressAcceptor acceptor, string UIName, string ComponentName, string parm, InputEventHandle <InputUILongPressEvent> callback)
    {
        InputlongPressRegisterInfo info = HeapObjectPool <InputlongPressRegisterInfo> .GetObject();

        info.eventKey      = InputUILongPressEvent.GetEventKey(UIName, ComponentName, parm);
        info.callBack      = callback;
        info.m_acceptor    = acceptor;
        info.m_OnLongPress = (type) =>
        {
            DispatchLongPressEvent(UIName, ComponentName, parm, type);
        };

        info.AddListener();
        acceptor.OnLongPress += info.m_OnLongPress;

        return(info);
    }
    public static InputEventRegisterInfo <InputUIOnEndDragEvent> AddOnEndDragListener(string UIName, string ComponentName, InputEventHandle <InputUIOnEndDragEvent> callback)
    {
        InputEventRegisterInfo <InputUIOnEndDragEvent> info = HeapObjectPool <InputEventRegisterInfo <InputUIOnEndDragEvent> > .GetObject();

        info.eventKey = InputUIOnEndDragEvent.GetEventKey(UIName, ComponentName);
        info.callBack = callback;

        InputManager.AddListener <InputUIOnEndDragEvent>(
            InputUIOnEndDragEvent.GetEventKey(UIName, ComponentName), callback);

        return(info);
    }
Ejemplo n.º 33
0
 public void AddOnClickListenerByCreate(Button button, string compName,InputEventHandle<InputUIOnClickEvent> callback, string parm = null)
 {
     InputEventRegisterInfo<InputUIOnClickEvent> info = InputUIEventProxy.AddOnClickListener(button, UIEventKey, compName, parm, callback);
     m_OnClickEvents.Add(info);
 }