MouseFlickTrigger ClassDelta Engine Documentation
Allows a mouse flick to be detected. View code on GitHub
Inheritance Hierarchy

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

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

public class MouseFlickTrigger : InputTrigger, 
	MouseTrigger

The MouseFlickTrigger type exposes the following members.

Constructors

  NameDescription
Public methodMouseFlickTrigger 
Initializes a new instance of the MouseFlickTrigger class
Public methodMouseFlickTrigger(Dictionary String, String )
Initializes a new instance of the MouseFlickTrigger 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 propertyIsActive (Inherited from Entity.)
Public propertyIsPauseable (Inherited from Trigger.)
Public propertyNumberOfComponents (Inherited from Entity.)
Public propertyPressTime
Public propertyStartPosition
Public propertyUpdatePriority (Inherited from Entity.)
Public propertyWasInvokedThisTick (Inherited from Trigger.)
Top
Remarks

Tests: DeltaEngine.Input.Tests.MouseFlickTriggerTests
Examples

3 unit tests call DeltaEngine.Input.MouseFlickTrigger
[Test]
public void ShowRedCircleOnFlick()
{
    new FontText(Font.Default, "Flick screen to show red circle", Rectangle.One);
    var ellipse = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Red);
    new Command(() => ellipse.Center = Vector2D.Half).Add(new MouseFlickTrigger());
    new Command(() => ellipse.Center = Vector2D.Zero).Add(new MouseButtonTrigger(State.Released));
}
[Test]
public void FlickWithMouse()
{
    var trigger = new MouseFlickTrigger();
    var mouse = Resolve<Mouse>() as MockMouse;
    if (mouse == null)
        return; //ncrunch: no coverage 
    bool flickHappened = false;
    trigger.Invoked += () => flickHappened = true;
    AdvanceMouseTick(mouse, State.Pressing, new Vector2D(0.5f, 0.5f));
    Assert.IsFalse(flickHappened);
    Assert.AreEqual(0.0f, trigger.PressTime);
    Assert.AreEqual(new Vector2D(0.5f, 0.5f), trigger.StartPosition);
    AdvanceMouseTick(mouse, State.Pressed, new Vector2D(0.52f, 0.5f));
    Assert.IsFalse(flickHappened);
    AdvanceMouseTick(mouse, State.Releasing, new Vector2D(0.8f, 0.8f));
    Assert.IsTrue(flickHappened);
    Assert.AreEqual(new Vector2D(0.5f, 0.5f), trigger.StartPosition);
}
[Test]
public void Creation()
{
    Assert.DoesNotThrow(() => new MouseFlickTrigger());
    Assert.Throws<MouseFlickTrigger.MouseFlickTriggerHasNoParameters>(
        () => new MouseFlickTrigger(new Dictionary<string, string> { { "Button", "Left" } }));
}
See Also