Exemplo n.º 1
0
 void CheckButtonReleased(MouseButton button)
 {
     if (currentState.StateFor(button) == ButtonState.Released && previousState.StateFor(button) == ButtonState.Pressed)
     {
         var args = new MouseEventData(MouseEventType.Up, currentFlags, currentTime, frame, previousState, currentState, button);
         eventSink.PushEvent(args);
     }
 }
Exemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            frame        += 1;
            currentTime   = gameTime.TotalGameTime;
            currentFlags  = InputFlagsHelper.Create(Keyboard.GetState(), currentState);
            previousState = currentState;
            if (hasTransform)
            {
                currentState = TransformState(Mouse.GetState());
            }
            else
            {
                currentState = Mouse.GetState();
            }

            // collect some valid state, so on the _next_ update call we can detect changes and process events.
            if (!initialized)
            {
                initialized = true;
                return;
            }

            for (var index = 0; index < buttons.Count; index++)
            {
                var button = buttons[index];
                CheckButtonPressed(button);
                CheckButtonReleased(button);
            }

            if (currentState.Position != previousState.Position)
            {
                var args = new MouseEventData(MouseEventType.Moved, currentFlags, currentTime, frame, previousState, currentState);
                eventSink.PushEvent(args);
            }

            if (currentState.ScrollWheelValue != previousState.ScrollWheelValue)
            {
                var args = new MouseEventData(MouseEventType.WheelMoved, currentFlags, currentTime, frame, previousState, currentState);
                eventSink.PushEvent(args);
            }
        }