MouseButtonTrigger ClassDelta Engine Documentation
Allows mouse button presses to be tracked. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Entities Entity
    DeltaEngine.Commands Trigger
      DeltaEngine.Commands InputTrigger
        DeltaEngine.Input MouseButtonTrigger

Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class MouseButtonTrigger : InputTrigger, 
	MovementTrigger, MouseTrigger

The MouseButtonTrigger type exposes the following members.

Constructors

  NameDescription
Public methodMouseButtonTrigger(Dictionary String, String )
Initializes a new instance of the MouseButtonTrigger class
Public methodMouseButtonTrigger(State)
Initializes a new instance of the MouseButtonTrigger class
Public methodMouseButtonTrigger(MouseButton, State)
Initializes a new instance of the MouseButtonTrigger class
Top
Methods

  NameDescription
Public methodAdd T  (Inherited from Entity.)
Public methodAddTag (Inherited from Entity.)
Public methodClearTags (Inherited from Entity.)
Public methodContains T  (Inherited from Entity.)
Public methodContainsBehavior T  (Inherited from Entity.)
Public methodContainsTag (Inherited from Entity.)
Protected methodDeactivate (Inherited from Entity.)
Public methodDispose (Inherited from Entity.)
Public methodGet T 
Gets a specific component, derived classes can return faster cached values (e.g. Entity2D) View code on GitHub
(Inherited from Entity.)
Protected methodGetActiveBehaviors (Inherited from Entity.)
Protected methodGetComponentsForSaving (Inherited from Entity.)
Public methodGetOrDefault T  (Inherited from Entity.)
Public methodGetTags (Inherited from Entity.)
Public methodHandleWithMouse
Public methodInvoke (Inherited from Trigger.)
Public methodRemove T  (Inherited from Entity.)
Public methodRemoveTag (Inherited from Entity.)
Public methodSet (Inherited from Entity.)
Public methodSetComponents (Inherited from Entity.)
Public methodStart T  (Inherited from Entity.)
Protected methodStartInputDevice (Overrides InputTrigger StartInputDevice .)
Public methodStop T  (Inherited from Entity.)
Public methodToString (Inherited from Entity.)
Public methodUpdate (Inherited from Trigger.)
Top
Fields

  NameDescription
Protected fieldcomponents (Inherited from Entity.)
Public fieldInvoked (Inherited from Trigger.)
Top
Properties

  NameDescription
Public propertyButton
Public propertyIsActive (Inherited from Entity.)
Public propertyIsPauseable (Inherited from Trigger.)
Public propertyMovement
Public propertyNumberOfComponents (Inherited from Entity.)
Public propertyState
Public propertyUpdatePriority (Inherited from Entity.)
Public propertyWasInvokedThisTick (Inherited from Trigger.)
Top
Remarks

Tests: DeltaEngine.Input.Tests.MouseButtonTriggerTests
Examples

5 unit tests call DeltaEngine.Input.MouseButtonTrigger
[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