Exemple #1
0
        public virtual bool Update(float deltaTime, InputDevice inputDevice)
        {
            if (!IsEnabled)
            {
                return(false);
            }

            var position          = inputDevice.Position;
            var shape             = GetBoundingRectangle();
            var previouslyPressed = IsPressed;

            IsPressed = inputDevice.IsTouching && shape.Contains(position);

            if (!previouslyPressed && IsPressed)
            {
                Pressed.Raise(this, EventArgs.Empty);
            }

            if (previouslyPressed && !IsPressed)
            {
                Released.Raise(this, EventArgs.Empty);

                if (shape.Contains(position))
                {
                    Click.Raise(this, EventArgs.Empty);
                }
            }

            return(true);
        }