Пример #1
0
        private bool GetMouseInput()
        {
            if (Input.GetMouseButtonDown(0))
            {
                _startPressPos = Input.mousePosition;
                _currPressPos  = _startPressPos;
                _isSwipeEnded  = false;
                TouchBegan?.Invoke(_startPressPos);
            }
            else if (Input.GetMouseButtonUp(0))
            {
                _endPressPos  = Input.mousePosition;
                _isSwipeEnded = true;
                TouchEnd?.Invoke(_endPressPos);

                return(true);
            }
            else if (Input.GetMouseButton(0))
            {
                _lastPressPos = _currPressPos;
                _currPressPos = Input.mousePosition;
                PointerDown?.Invoke(_currPressPos);

                return(true);
            }

            return(false);
        }
        public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);

            var touch = touches.AnyObject as UITouch;

            if (touch != null)
            {
                TouchBegan?.Invoke(this, touch);
            }
        }
Пример #3
0
        private bool GetTouchInput()
        {
            if (Input.touches.Length > 0)
            {
                var touch = Input.GetTouch(0);
                switch (touch.phase)
                {
                case TouchPhase.Began:
                    _startPressPos = touch.position;
                    _currPressPos  = _startPressPos;
                    _isSwipeEnded  = false;
                    TouchBegan?.Invoke(touch.position);

                    break;

                case TouchPhase.Ended:
                case TouchPhase.Canceled:
                    _endPressPos  = touch.position;
                    _isSwipeEnded = true;

                    TouchEnd?.Invoke(touch.position);

                    return(true);

                case TouchPhase.Moved:
                case TouchPhase.Stationary:
                    _lastPressPos = _currPressPos;
                    _currPressPos = touch.position;

                    PointerDown?.Invoke(touch.position);

                    return(true);
                }
            }

            return(false);
        }
Пример #4
0
 /// <summary>
 /// Protected overridable handler that raises TouchBegan event.
 /// </summary>
 protected virtual void OnTouchBegan(TouchEventArgs args)
 {
     TouchBegan?.Invoke(this, args);
 }
 public void OnTouchBegan(double positionX, double positionY)
 {
     TouchBegan?.Invoke(Content, new PositionEventArgs(positionX, positionY));
 }
Пример #6
0
 protected virtual void OnTouchBegan(ITouchEventArgs e) =>
 TouchBegan?.Invoke(this, e);