public void RemoveFocus(EventCallBack callBack)
 {
     LastEntry.Remove(callBack);
     CurrentEntry.Remove(callBack);
     LastFocus.Remove(callBack);
     MultiFocus.Remove(callBack);
     callBack.Pressed = false;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 子线程
 /// </summary>
 public void Dispatch(ModelElement root)
 {
     if (IsLeftButtonDown | IsRightButtonDown | IsMiddleButtonDown)
     {
         List <EventCallBack> tmp = MultiFocus;
         LastFocus.Clear();
         MultiFocus = LastFocus;
         LastFocus  = tmp;
     }
     EventCallBack.DispatchEvent(this, root);
     if (IsLeftButtonDown | IsRightButtonDown | IsMiddleButtonDown)
     {
         for (int i = 0; i < LastFocus.Count; i++)
         {
             var f = LastFocus[i];
             for (int j = 0; j < MultiFocus.Count; j++)
             {
                 if (f == MultiFocus[j])
                 {
                     goto label2;
                 }
             }
             if (!f.Pressed)
             {
                 f.OnLostFocus(this);
             }
             label2 :;
         }
     }
     else if (IsLeftButtonUp | IsRightButtonUp | IsMiddleButtonUp)
     {
         for (int i = 0; i < MultiFocus.Count; i++)
         {
             var f = MultiFocus[i];
             f.Pressed = false;
             f.OnDragEnd(this);
         }
     }
     else
     {
         for (int i = 0; i < MultiFocus.Count; i++)
         {
             MultiFocus[i].OnFocusMove(this);
         }
     }
     if (IsMouseWheel)
     {
         for (int i = 0; i < MultiFocus.Count; i++)
         {
             var f = MultiFocus[i];
             if (f.MouseWheel != null)
             {
                 f.MouseWheel(f, this);
             }
         }
     }
     CheckMouseLeave();
 }
 public void AddFocus(EventCallBack eve)
 {
     if (MultiFocus.Contains(eve))
     {
         return;
     }
     MultiFocus.Add(eve);
     eve.Pressed = isPressed;
     if (eve.Pressed)
     {
         eve.pressTime = EventTicks;
     }
 }
Ejemplo n.º 4
0
        void OnLostFocus(EventCallBack eventCall, UserAction action)
        {
            TextInput text = eventCall as TextInput;

            if (text == InputEvent)
            {
                if (InputEvent.OnSubmit != null)
                {
                    InputEvent.OnSubmit(InputEvent);
                }
                InputEvent = null;
            }
            Editing = false;
            SetShowText();
            ThreadMission.InvokeToMain((o) => { Keyboard.EndInput(); }, null);
        }
        public static object RegEvent(ModelElement element, Type type)
        {
            for (int i = 0; i < events.Count; i++)
            {
                if (events[i].Context == element)
                {
                    events.RemoveAt(i);
                    break;
                }
            }
            EventCallBack u = Activator.CreateInstance(type) as EventCallBack;

            u.Context         = element;
            u.g_color         = u.Context.color;
            element.baseEvent = u;
            events.Add(u);
            u.Initial();
            return(u);
        }
 static void Reset(EventCallBack eventCall)
 {
     eventCall.PointerDown  = null;
     eventCall.PointerUp    = null;
     eventCall.Click        = null;
     eventCall.PointerEntry = null;
     eventCall.PointerMove  = null;
     eventCall.PointerLeave = null;
     eventCall.Drag         = null;
     eventCall.DragEnd      = null;
     eventCall.Scrolling    = null;
     eventCall.AutoColor    = true;
     eventCall.forbid       = false;
     eventCall.mVelocity    = Vector2.zero;
     eventCall.maxVelocity  = Vector2.zero;
     eventCall.CutRect      = false;
     eventCall.ForceEvent   = false;
     eventCall.Penetrate    = false;
 }
Ejemplo n.º 7
0
        void OnClick(EventCallBack eventCall, UserAction action)
        {
            TextInput input = eventCall as TextInput;

            if (input == null)
            {
                return;
            }
            InputEvent           = input;
            textInfo.startSelect = GetPressIndex(textInfo, this, action, ref textInfo.startDock);
            textInfo.endSelect   = -1;
            textInfo.CaretStyle  = 1;
            ChangePoint(textInfo);
            bool pass = InputEvent.contentType == ContentType.Password ? true : false;

            Keyboard.OnInput(textInfo.text, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit);
            InputCaret.SetParent(Target);
            InputCaret.ChangeCaret(textInfo);
        }
Ejemplo n.º 8
0
        void OnClick(EventCallBack eventCall, UserAction action)
        {
            TextInput input = eventCall as TextInput;

            if (input == null)
            {
                return;
            }
            InputEvent           = input;
            textInfo.startSelect = GetPressIndex(textInfo, this, action, ref textInfo.startDock) + textInfo.StartIndex;
            textInfo.endSelect   = -1;
            textInfo.CaretStyle  = 1;
            selectChanged        = true;
            ThreadMission.InvokeToMain((o) => {
                bool pass = InputEvent.contentType == ContentType.Password ? true : false;
                Keyboard.OnInput(textInfo.text, InputEvent.touchType, InputEvent.multiLine, pass, CharacterLimit);
                InputCaret.SetParent(Context.Context);
                InputCaret.ChangeCaret(textInfo);
            }, null);
        }
 public bool ExistFocus(EventCallBack eve)
 {
     return(MultiFocus.Contains(eve));
 }
        static void DuringSlide(EventCallBack back)
        {
            if (back.mVelocity.x == 0 & back.mVelocity.y == 0)
            {
                return;
            }
            back.xTime += UserAction.TimeSlice;
            back.yTime += UserAction.TimeSlice;
            float x = 0, y = 0;
            bool  endx = false, endy = false;

            if (back.mVelocity.x != 0)
            {
                float t = (float)MathH.PowDistance(back.DecayRateX, back.maxVelocity.x, back.xTime);
                x          = t - back.lastX;
                back.lastX = t;
                float vx = Mathf.Pow(back.DecayRateX, back.xTime) * back.maxVelocity.x;
                if (vx <0.001f& vx> -0.001f)
                {
                    back.mVelocity.x = 0;
                    endx             = true;
                }
                else
                {
                    back.mVelocity.x = vx;
                }
            }
            if (back.mVelocity.y != 0)
            {
                float t = (float)MathH.PowDistance(back.DecayRateY, back.maxVelocity.y, back.yTime);
                y          = t - back.lastY;
                back.lastY = t;
                float vy = Mathf.Pow(back.DecayRateY, back.yTime) * back.maxVelocity.y;
                if (vy <0.001f& vy> -0.001f)
                {
                    back.mVelocity.y = 0;
                    endy             = true;
                }
                else
                {
                    back.mVelocity.y = vy;
                }
            }
            if (back.Scrolling != null)
            {
                back.Scrolling(back, new Vector2(x, y));
            }
            if (endx)
            {
                if (back.ScrollEndX != null)
                {
                    back.ScrollEndX(back);
                }
            }
            if (endy)
            {
                if (back.ScrollEndY != null)
                {
                    back.ScrollEndY(back);
                }
            }
        }
Ejemplo n.º 11
0
        public static int GetPressIndex(TextInfo info, EventCallBack callBack, UserAction action, ref int dock)
        {
            dock = 0;
            if (info == null)
            {
                return(0);
            }
            if (info.text == "" | info.text == null)
            {
                return(0);
            }
            IList <UILineInfo> lines = info.lines;

            if (lines == null)
            {
                return(0);
            }

            IList <UIVertex> verts = info.vertex;
            float            lx    = verts[0].position.x;
            float            ty    = verts[0].position.y;
            float            dy    = verts[verts.Count - 1].position.y;

            var   pos   = callBack.GlobalPosition;
            var   scale = callBack.GlobalScale;
            float mx    = action.CanPosition.x - pos.x;

            mx *= scale.x;
            float my = action.CanPosition.y - pos.y;

            my *= scale.y;
            int r = 0;//行

            if (my < ty)
            {
                if (my < dy)
                {
                    r = lines.Count - 1;
                }
                else
                {
                    for (int i = lines.Count - 1; i >= 0; i--)
                    {
                        if (my < lines[i].topY)
                        {
                            r = i;
                            break;
                        }
                    }
                }
            }
            if (mx > lx)
            {
                int s     = lines[r].startCharIdx;
                int index = s * 4;
                int end   = verts.Count - index;

                float ox = verts[index].position.x;
                for (int i = 0; i < end; i += 4)
                {
                    float tx = verts[index].position.x;
                    if (tx <ox | tx> mx)
                    {
                        index -= 4;
                        goto lable;
                    }
                    ox     = tx;
                    index += 4;
                }
                return(info.visibleCount);

                lable :;
                float ax = verts[index].position.x;
                float bx = verts[index + 2].position.x;
                float cx = ax + (bx - ax) * 0.5f;
                index /= 4;
                if (mx > cx)//靠右
                {
                    index++;
                    dock = 1;
                }
                return(index);
            }
            else
            {
                return(lines[r].startCharIdx);
            }
        }