ClickTest() public method

public ClickTest ( ) : DisplayObject
return DisplayObject
示例#1
0
        void HandleMouseEvents()
        {
            TouchInfo touch = _touches[0];

            if (touch.x != _touchPosition.x || touch.y != _touchPosition.y)
            {
                touch.x = _touchPosition.x;
                touch.y = _touchPosition.y;
                touch.UpdateEvent();
                onTouchMove.Call(touch.evt);

                if (touch.lastRollOver != touch.target)
                {
                    HandleRollOver(touch);
                }
            }

            if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
            {
                if (!touch.began)
                {
                    _touchCount = 1;
                    touch.begin();
                    touch.button = Input.GetMouseButtonDown(2) ? 2 : (Input.GetMouseButtonDown(1) ? 1 : 0);
                    this.focus   = touch.target;

                    if (touch.target != null)
                    {
                        touch.UpdateEvent();
                        touch.target.onTouchBegin.BubbleCall(touch.evt);
                    }
                }
            }
            if (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1) || Input.GetMouseButtonUp(2))
            {
                if (touch.began)
                {
                    _touchCount = 0;
                    touch.end();

                    DisplayObject clickTarget = touch.ClickTest();
                    if (clickTarget != null)
                    {
                        touch.UpdateEvent();

                        if (Input.GetMouseButtonUp(1))
                        {
                            clickTarget.onRightClick.BubbleCall(touch.evt);
                        }
                        else
                        {
                            clickTarget.onClick.BubbleCall(touch.evt);
                        }
                    }
                }
            }
        }
示例#2
0
        void HandleCustomInput()
        {
            Vector2 pos = _customInputPos;

            pos.y = stageHeight - pos.y;
            TouchInfo touch = _touches[0];

            if (touch.x != pos.x || touch.y != pos.y)
            {
                touch.x = pos.x;
                touch.y = pos.y;
                touch.UpdateEvent();
                onTouchMove.Call(touch.evt);

                if (touch.lastRollOver != touch.target)
                {
                    HandleRollOver(touch);
                }
            }

            if (_customInputButtonDown)
            {
                if (!touch.began)
                {
                    _touchCount = 1;
                    touch.begin();
                    this.focus = touch.target;

                    if (touch.target != null)
                    {
                        touch.UpdateEvent();
                        touch.target.onTouchBegin.BubbleCall(touch.evt);
                    }
                }
            }
            else if (touch.began)
            {
                _touchCount = 0;
                touch.end();

                DisplayObject clickTarget = touch.ClickTest();
                if (clickTarget != null)
                {
                    touch.UpdateEvent();
                    clickTarget.onClick.BubbleCall(touch.evt);
                }
            }
        }
示例#3
0
        void HandleTouchEvents()
        {
            int tc = Input.touchCount;

            for (int i = 0; i < tc; ++i)
            {
                Touch uTouch = Input.GetTouch(i);

                if (uTouch.phase == TouchPhase.Stationary)
                {
                    continue;
                }

                Vector2 pos = uTouch.position;
                pos.y = stageHeight - pos.y;

                TouchInfo touch = null;
                for (int j = 0; j < 5; j++)
                {
                    if (_touches[j].touchId == uTouch.fingerId)
                    {
                        touch = _touches[j];
                        break;
                    }
                }
                if (touch == null)
                {
                    continue;
                }

                if (touch.x != pos.x || touch.y != pos.y)
                {
                    touch.x = pos.x;
                    touch.y = pos.y;
                    touch.UpdateEvent();
                    onTouchMove.Call(touch.evt);

                    //no rollover/rollout on mobile
                }

                if (uTouch.phase == TouchPhase.Began)
                {
                    if (!touch.began)
                    {
                        _touchCount++;
                        touch.begin();
                        this.focus = touch.target;

                        if (touch.target != null)
                        {
                            touch.UpdateEvent();
                            touch.target.onTouchBegin.BubbleCall(touch.evt);
                        }
                    }
                }
                else if (uTouch.phase == TouchPhase.Canceled || uTouch.phase == TouchPhase.Ended)
                {
                    if (touch.began)
                    {
                        _touchCount--;
                        touch.end();

                        DisplayObject clickTarget = touch.ClickTest();
                        if (clickTarget != null)
                        {
                            touch.clickCount = uTouch.tapCount;
                            touch.UpdateEvent();
                            clickTarget.onClick.BubbleCall(touch.evt);
                        }
                    }

                    touch.Reset();
                }
            }
        }
示例#4
0
        internal void HandleMouseEvents()
        {
            MouseState mouseState = Mouse.GetState();

            _touchPosition    = new Vector2(mouseState.Position.X, mouseState.Position.Y);
            _touchTarget      = HitTest(_touchPosition, true);
            _touchInfo.target = _touchTarget;

            if (Math.Abs(_touchInfo.x - _touchPosition.X) > 0 || Math.Abs(_touchInfo.y - _touchPosition.Y) > 0)
            {
                _touchInfo.x = _touchPosition.X;
                _touchInfo.y = _touchPosition.Y;
                _touchInfo.Move();
            }

            if (_touchInfo.lastRollOver != _touchInfo.target)
            {
                HandleRollOver(_touchInfo);
            }

            if (mouseState.LeftButton == ButtonState.Pressed ||
                mouseState.RightButton == ButtonState.Pressed ||
                mouseState.MiddleButton == ButtonState.Pressed)
            {
                if (!_touchInfo.began)
                {
                    _touchInfo.Begin();
                    _touchInfo.button =
                        (mouseState.LeftButton == ButtonState.Pressed)
                                                        ? 0
                                                        : (mouseState.RightButton == ButtonState.Pressed ? 1 : 2);
                    this.focus = _touchInfo.target;

                    _touchInfo.UpdateEvent();
                    _touchInfo.target.BubbleEvent("onTouchBegin", _touchInfo.evt);
                }
            }
            else if (mouseState.LeftButton == ButtonState.Released ||
                     mouseState.RightButton == ButtonState.Released ||
                     mouseState.MiddleButton == ButtonState.Released)
            {
                if (_touchInfo.began)
                {
                    _touchInfo.End();

                    DisplayObject clickTarget = _touchInfo.ClickTest();
                    if (clickTarget != null)
                    {
                        _touchInfo.UpdateEvent();

                        if (_touchInfo.button == 1)
                        {
                            clickTarget.BubbleEvent("onRightClick", _touchInfo.evt);
                        }
                        else
                        {
                            clickTarget.BubbleEvent("onClick", _touchInfo.evt);
                        }
                    }

                    _touchInfo.button = -1;
                }
            }

            int deltaWheel = mouseState.ScrollWheelValue - _lastScrollWheelValue;

            if (deltaWheel != 0)
            {
                if (_touchTarget != null)
                {
                    _touchInfo.mouseWheelDelta = -deltaWheel;
                    _touchInfo.UpdateEvent();
                    _touchTarget.BubbleEvent("onMouseWheel", _touchInfo.evt);
                    _touchInfo.mouseWheelDelta = 0;
                }

                _lastScrollWheelValue = mouseState.ScrollWheelValue;
            }
        }
示例#5
0
        void HandleTouchEvents()
        {
            int tc = Input.touchCount;

            for (int i = 0; i < tc; ++i)
            {
                Touch uTouch = Input.GetTouch(i);

                if (uTouch.phase == TouchPhase.Stationary)
                {
                    continue;
                }

                Vector2 pos = uTouch.position;
                pos.y = stageHeight - pos.y;

                TouchInfo touch = null;
                for (int j = 0; j < 5; j++)
                {
                    if (_touches[j].touchId == uTouch.fingerId)
                    {
                        touch = _touches[j];
                        break;
                    }
                }
                if (touch == null)
                {
                    continue;
                }

                if (touch.x != pos.x || touch.y != pos.y)
                {
                    touch.x = pos.x;
                    touch.y = pos.y;
                    if (touch.began)
                    {
                        touch.Move();
                    }
                }

                if (touch.lastRollOver != touch.target)
                {
                    HandleRollOver(touch);
                }

                if (uTouch.phase == TouchPhase.Began)
                {
                    if (!touch.began)
                    {
                        _touchCount++;
                        touch.Begin();
                        touch.button = 0;
                        this.focus   = touch.target;

                        touch.UpdateEvent();
                        touch.target.BubbleEvent("onTouchBegin", touch.evt);
                    }
                }
                else if (uTouch.phase == TouchPhase.Canceled || uTouch.phase == TouchPhase.Ended)
                {
                    if (touch.began)
                    {
                        _touchCount--;
                        touch.End();

                        if (uTouch.phase != TouchPhase.Canceled)
                        {
                            DisplayObject clickTarget = touch.ClickTest();
                            if (clickTarget != null)
                            {
                                touch.clickCount = uTouch.tapCount;
                                touch.UpdateEvent();
                                clickTarget.BubbleEvent("onClick", touch.evt);
                            }
                        }

                        touch.target = null;
                        HandleRollOver(touch);

                        touch.touchId = -1;
                    }
                }
            }
        }
示例#6
0
        internal void HandleMouseEvents(int iX, int iY, EHARDWAREMOUSEEVENT eHardwareMouseEvent, int wheelDelta)
        {
            if (wheelDelta != 0)
            {
                if (_touchTarget != null)
                {
                    _touchInfo.mouseWheelDelta = -wheelDelta;
                    _touchInfo.UpdateEvent();
                    _touchTarget.onMouseWheel.BubbleCall(_touchInfo.evt);
                    _touchInfo.mouseWheelDelta = 0;
                }
                return;
            }

            _touchPosition    = new Vector2(iX, iY);
            _touchTarget      = HitTest(_touchPosition, true);
            _touchInfo.target = _touchTarget;

            if (_touchInfo.x != _touchPosition.x || _touchInfo.y != _touchPosition.y)
            {
                _touchInfo.x = _touchPosition.x;
                _touchInfo.y = _touchPosition.y;
                _touchInfo.Move();
            }

            if (_touchInfo.lastRollOver != _touchInfo.target)
            {
                HandleRollOver(_touchInfo);
            }

            if (eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_LBUTTONDOWN ||
                eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_RBUTTONDOWN ||
                eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_MBUTTONDOWN ||
                eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_LBUTTONDOUBLECLICK)
            {
                if (!_touchInfo.began)
                {
                    _touchInfo.Begin();
                    _touchInfo.button = (eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_LBUTTONDOWN || eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_LBUTTONDOUBLECLICK) ? 0 : (eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_RBUTTONDOWN ? 1 : 2);
                    this.focus        = _touchInfo.target;

                    _touchInfo.UpdateEvent();
                    _touchInfo.target.BubbleEvent("onTouchBegin", _touchInfo.evt);
                }
            }
            if (eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_LBUTTONUP ||
                eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_RBUTTONUP ||
                eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_MBUTTONUP)
            {
                if (_touchInfo.began)
                {
                    _touchInfo.button = eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_LBUTTONUP ? 0 : (eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_RBUTTONUP ? 1 : 2);
                    _touchInfo.End();

                    DisplayObject clickTarget = _touchInfo.ClickTest();
                    if (clickTarget != null)
                    {
                        _touchInfo.UpdateEvent();

                        if (eHardwareMouseEvent == EHARDWAREMOUSEEVENT.HARDWAREMOUSEEVENT_RBUTTONUP)
                        {
                            clickTarget.BubbleEvent("onRightClick", _touchInfo.evt);
                        }
                        else
                        {
                            clickTarget.BubbleEvent("onClick", _touchInfo.evt);
                        }
                    }

                    _touchInfo.button = -1;
                }
            }
        }