Provides the mouse position, mouse button states and allows to set the mouse position.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Entities UpdateBehavior
DeltaEngine.Input InputDevice
DeltaEngine.Input Mouse
DeltaEngine.Input.GLFW2 GLFWMouse
DeltaEngine.Input.GLFW3 GLFWMouse
DeltaEngine.Input.Mocks MockMouse
DeltaEngine.Input.SharpDX SharpDXMouse
DeltaEngine.Input.SlimDX SlimDXMouse
DeltaEngine.Input.Windows WindowsMouse
DeltaEngine.Input.Xna XnaMouse
Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Mouse type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Mouse | Initializes a new instance of the Mouse class |
Methods
Name | Description | |
---|---|---|
Dispose | (Inherited from InputDevice.) | |
GetButtonState | ||
SetNativePosition | ||
Update | (Overrides UpdateBehavior Update(IEnumerable Entity ).) |
Properties
Name | Description | |
---|---|---|
IsAvailable | (Inherited from InputDevice.) | |
LeftButton | ||
MiddleButton | ||
Position | ||
RightButton | ||
ScrollWheelValue |
Total accumulated mouse scroll wheel value. Compare with last frame to see the change (see
MouseZoomTrigger). Will not use multipliers like 120 to report one mouse wheel up change.
One mouse wheel up change results in a value change of +1, down is -1.
View code on GitHub | |
X1Button | ||
X2Button |
Remarks
Examples
[Test] public void PressLeftMouseButtonToCloseWindow() { new FontText(Font.Default, "Press Left Mouse Button to close window", Rectangle.One); new Command(() => Resolve<Window>().CloseAfterFrame()).Add(new MouseButtonTrigger()); }
[Test] public void ClickAndHoldToShowRedEllipseAtMousePosition() { var ellipse = new Ellipse(new Rectangle(-0.1f, -0.1f, 0.1f, 0.1f), Color.Red); new Command(position => ellipse.Center = position).Add(new MouseButtonTrigger(State.Pressed)); }
[Test, CloseAfterFirstFrame] public void Create() { var trigger = new MouseButtonTrigger(MouseButton.Right, State.Pressed); Assert.AreEqual(MouseButton.Right, trigger.Button); Assert.AreEqual(State.Pressed, trigger.State); Assert.AreEqual(MouseButton.Left, new MouseButtonTrigger().Button); Assert.AreEqual(State.Pressing, new MouseButtonTrigger().State); Assert.AreEqual(MouseButton.Left, new MouseButtonTrigger(State.Pressed).Button); Assert.AreEqual(State.Pressed, new MouseButtonTrigger(State.Pressed).State); }
See Also