aboutsummaryrefslogtreecommitdiff
path: root/V3/Input/Internal/MouseEvent.cs
blob: f8024aa8aac6be761dfaf89fc728877e5b8687f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace V3.Input.Internal
{
    /// <summary>
    /// Default implementation of an event that is sent when a mouse button is
    /// pressed or released.
    /// </summary>
    internal sealed class MouseEvent : IMouseEvent
    {
        /// <summary>
        /// The mouse button that was pressed or released.
        /// </summary>
        public MouseButton MouseButton { get; }
        /// <summary>
        /// The state of the mouse button (pressed or released?).
        /// </summary>
        public ButtonState ButtonState { get; }
        /// <summary>
        /// The position where the mouse button was pressed the last time.
        /// </summary>
        public Point PositionPressed { get; }
        /// <summary>
        /// The position where the mouse button was released if this is a
        /// release event, null otherwise.
        /// </summary>
        public Point? PositionReleased { get; }
        /// <summary>
        /// True if PositionReleased is a valid on-screen position, otherwise
        /// false.
        /// </summary>
        public bool ReleasedOnScreen { get; }

        /// <summary>
        /// Creates a new mouse event with the given data.
        /// </summary>
        /// <param name="mouseButton">the mouse button that was pressed or
        ///     released</param>
        /// <param name="buttonState">the type of the event (pressed or
        ///     released?)</param>
        /// <param name="positionPressed">the position of the last press of
        ///     the button</param>
        /// <param name="positionReleased">the position of the release of the
        ///     button if this is a release event, or null otherwise</param>
        /// <param name="releasedOnScreen">true if positionReleased is a valid
        ///     on-screen position.</param>
        public MouseEvent(MouseButton mouseButton, ButtonState buttonState, Point positionPressed, Point? positionReleased, bool releasedOnScreen)
        {
            MouseButton = mouseButton;
            ButtonState = buttonState;
            PositionPressed = positionPressed;
            PositionReleased = positionReleased;
            ReleasedOnScreen = releasedOnScreen;
        }
    }
}