예제 #1
0
 public static UIEventListener.VoidDelegate AddLink(UILabel lbl, Action <object> handler)
 {
     if (clickDic.ContainsKey(lbl.gameObject))
     {
         Dictionary <Action <object>, UIEventListener.VoidDelegate> dic = clickDic[lbl.gameObject];
         if (dic.ContainsKey(handler))
         {
             return(null);
         }
     }
     else
     {
         clickDic.Add(lbl.gameObject, new Dictionary <Action <object>, UIEventListener.VoidDelegate>());
         AddPress(lbl.gameObject, OnLabelPress, lbl);
         AddHover(lbl.gameObject, (o, b) => { if (!b)
                                              {
                                                  FuncUtil.SetCursor("CURSOR_NORMAL");
                                              }
                  });
     }
     UIEventListener.VoidDelegate de = delegate(GameObject go1) {
         string url = lbl.GetUrlAtPosition(UICamera.lastHit.point);
         if (url != null)
         {
             handler.DynamicInvoke(url);
         }
     };
     UIEventListener.Get(lbl.gameObject).onClick += de;
     clickDic[lbl.gameObject].Add(handler, de);
     return(de);
 }
예제 #2
0
 protected override void OnHover(bool b)
 {
     base.OnHover(b);
     if (b && ToolTip != "")
     {
         ToolTipManager.Show(ToolTip, tipDely, tipWidth);
     }
     else if (b == false)
     {
         ToolTipManager.Hide();
     }
     if (b == true && _isEnable)
     {
         FuncUtil.SetCursor("CURSOR_CLICK_OVER");
         //currentTouch为null是为了防止在按钮上放开鼠标时触发OnHover
         //当鼠标离开时currentTouch为null,鼠标进入时currentTouch也为null,鼠标按下时才不为null
         if (UICamera.currentTouch == null)
         {
             if (_rollOverFun != null)
             {
                 _rollOverFun(gameObject);
             }
         }
     }
     else if (_isEnable == false)
     {
         FuncUtil.SetCursor("CURSOR_NORMAL");
     }
     else
     {
         if (_rollOutFun != null)
         {
             _rollOutFun(gameObject);
         }
         //if (/*!UICamera.IsPressIng && */FuncUtil.IsUICursor()) {
         //    FuncUtil.SetCursor("CURSOR_NORMAL");
         //}
     }
     if (relateChild)
     {
         GetChildBtns();
         foreach (Component child in childBtn)
         {
             if (child != this)
             {
                 (child as CButton).isEnabled = true;
                 (child as CButton).OnHover(b);
             }
         }
     }
 }
예제 #3
0
 public static UIEventListener.VoidDelegate AddClick(GameObject go, Action <object> handler, object arg = null)
 {
     if (clickDic.ContainsKey(go))
     {
         Dictionary <Action <object>, UIEventListener.VoidDelegate> dic = clickDic[go];
         if (dic.ContainsKey(handler))
         {
             return(null);
         }
     }
     else
     {
         clickDic.Add(go, new Dictionary <Action <object>, UIEventListener.VoidDelegate>());
         if (go.name != "PanelBG" && go.GetComponent <UIWidget>() != null && go.GetComponent <CButton>() == null)
         {
             var label = go.GetComponent <UILabel>();
             if (label == null)
             {
                 AddPress(go, (o, b) => FuncUtil.SetCursor(b ? "CURSOR_CLICK_DOWN" : "CURSOR_NORMAL"));
                 AddHover(go, (o, b) =>
                          FuncUtil.SetCursor(b ? "CURSOR_CLICK_OVER" : "CURSOR_NORMAL"));
             }
             else
             {
                 AddHover(go, (o, b) => { if (!b)
                                          {
                                              FuncUtil.SetCursor("CURSOR_NORMAL");
                                          }
                          });
                 AddPress(go, OnLabelPress, label);
             }
         }
     }
     UIEventListener.VoidDelegate de = delegate(GameObject go1) {
         handler.DynamicInvoke(arg);
     };
     UIEventListener.Get(go).onClick += de;
     clickDic[go].Add(handler, de);
     return(de);
 }
예제 #4
0
        protected override void OnPress(bool b)
        {
            if (isEnabled == false)
            {
                return;
            }
            base.OnPress(b);
            if (b == true)
            {
                if (_mouseDownFun != null)
                {
                    _mouseDownFun(gameObject);
                }
                FuncUtil.SetCursor("CURSOR_CLICK_DOWN");
            }
            else
            {
                if (_mouseUpFun != null)
                {
                    _mouseUpFun(gameObject);
                }
                //if (!UICamera.IsPressIng && FuncUtil.IsUICursor()) {
                //    FuncUtil.SetCursor("CURSOR_NORMAL");
                //}
            }

            if (relateChild)
            {
                GetChildBtns();
                foreach (Component child in childBtn)
                {
                    if (child != this)
                    {
                        (child as CButton).isEnabled = true;
                        (child as CButton).OnPress(b);
                    }
                }
            }
        }
예제 #5
0
        private static void OnLabelPress(object obj, bool isPress)
        {
            if (!isPress)
            {
                FuncUtil.SetCursor("CURSOR_NORMAL"); return;
            }
            var label = obj as UILabel;

            if (label == null)
            {
                return;
            }
            string url = label.GetUrlAtPosition(UICamera.lastHit.point);

            if (url != null)
            {
                FuncUtil.SetCursor("CURSOR_CLICK_DOWN");
            }
            else
            {
                FuncUtil.SetCursor("CURSOR_NORMAL");
            }
        }
예제 #6
0
 void OnPress(bool isPress)
 {
     FuncUtil.SetCursor(isPress ? "CURSOR_CLICK_DOWN" : "CURSOR_NORMAL");
 }
예제 #7
0
 void OnHover(bool isSelected)
 {
     FuncUtil.SetCursor(isSelected ? "CURSOR_CLICK_OVER" : "CURSOR_NORMAL");
 }