Normally we only care about left, middle or right mouse button clicks, rarely for the others.
View code on GitHub
Namespace: DeltaEngine.InputAssembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Members
Member name | Value | Description | |
---|---|---|---|
Left | 0 | ||
Middle | 1 | ||
Right | 2 | ||
X1 | 3 | ||
X2 | 4 |
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