예제 #1
0
        private void pointerUpdatedHandler(object sender, MetaGestureEventArgs metaGestureEventArgs)
        {
            var pointer = metaGestureEventArgs.Pointer;

            if (pointer.InputSource == (IInputSource)this)
            {
                return;
            }

            Pointer newPointer;

            if (!map.TryGetValue(pointer.Id, out newPointer))
            {
                return;
            }
            HitData hit;

            if (!PointerUtils.IsPointerOnTarget(pointer, transform, out hit))
            {
                return;
            }
            newPointer.Position = processCoords(hit.RaycastHit.textureCoord);
            newPointer.Flags    = pointer.Flags | Pointer.FLAG_ARTIFICIAL;
            updatePointer(newPointer);
        }
        private void pointersReleasedHandler(object sender, PointerEventArgs pointerEventArgs)
        {
            var over  = pointers.Count;
            var p     = pointerEventArgs.Pointers;
            var count = p.Count;

            for (var i = 0; i < count; i++)
            {
                var pointer = p[i];
                if (PointerUtils.IsPointerOnTarget(pointer, transform))
                {
                    pointers.Add(pointer.Id);
                }
                else
                {
                    pointers.Remove(pointer.Id);
                }
            }

            if (over == 0 && pointers.Count > 0)
            {
                dispatchOver();
            }
            else if (over > 0 && pointers.Count == 0)
            {
                dispatchOut();
            }
        }
        private void pointersUpdatedHandler(object sender, PointerEventArgs pointerEventArgs)
        {
            var over  = pointers.Count;
            var p     = pointerEventArgs.Pointers;
            var count = p.Count;

            for (var i = 0; i < count; i++)
            {
                var pointer = p[i];
                if ((pointer.Buttons & Pointer.PointerButtonState.AnyButtonPressed) != 0)
                {
                    continue;                                                                       // we ignore pressed pointers
                }
                if (PointerUtils.IsPointerOnTarget(pointer, transform))
                {
                    pointers.Add(pointer.Id);
                }
                else
                {
                    pointers.Remove(pointer.Id);
                }
            }

            if (over == 0 && pointers.Count > 0)
            {
                dispatchOver();
            }
            else if (over > 0 && pointers.Count == 0)
            {
                dispatchOut();
            }
        }
예제 #4
0
        public override bool CancelPointer(Pointer pointer, bool shouldReturn)
        {
            base.CancelPointer(pointer, shouldReturn);

            map.Remove(pointer.Id);
            if (shouldReturn)
            {
                HitData hit;
                if (PointerUtils.IsPointerOnTarget(pointer, transform, out hit))
                {
                    var newPointer = PointerFactory.Create(pointer.Type, this);
                    newPointer.CopyFrom(pointer);
                    newPointer.Position = processCoords(hit.RaycastHit.textureCoord);
                    addPointer(newPointer);
                    pressPointer(newPointer);
                    map.Add(pointer.Id, newPointer);
                }
            }
            return(true);
        }
예제 #5
0
 /// <inheritdoc />
 protected override bool shouldCachePointerPosition(Pointer value)
 {
     // Points must be over target when released
     return(PointerUtils.IsPointerOnTarget(value, cachedTransform));
 }