Allows a touch hold to be detected.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Entities Entity
DeltaEngine.Commands Trigger
DeltaEngine.Commands InputTrigger
DeltaEngine.Input TouchHoldTrigger
Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The TouchHoldTrigger type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TouchHoldTrigger(Dictionary String, String ) | Initializes a new instance of the TouchHoldTrigger class | |
TouchHoldTrigger(Rectangle, Single) | Initializes a new instance of the TouchHoldTrigger class |
Methods
Name | Description | |
---|---|---|
Add T | (Inherited from Entity.) | |
AddTag | (Inherited from Entity.) | |
ClearTags | (Inherited from Entity.) | |
Contains T | (Inherited from Entity.) | |
ContainsBehavior T | (Inherited from Entity.) | |
ContainsTag | (Inherited from Entity.) | |
Deactivate | (Inherited from Entity.) | |
Dispose | (Inherited from Entity.) | |
Get T |
Gets a specific component, derived classes can return faster cached values (e.g. Entity2D)
View code on GitHub (Inherited from Entity.) | |
GetActiveBehaviors | (Inherited from Entity.) | |
GetComponentsForSaving | (Inherited from Entity.) | |
GetOrDefault T | (Inherited from Entity.) | |
GetTags | (Inherited from Entity.) | |
HandleWithTouch | ||
Invoke | (Inherited from Trigger.) | |
IsHovering | ||
Remove T | (Inherited from Entity.) | |
RemoveTag | (Inherited from Entity.) | |
Set | (Inherited from Entity.) | |
SetComponents | (Inherited from Entity.) | |
Start T | (Inherited from Entity.) | |
StartInputDevice | (Overrides InputTrigger StartInputDevice .) | |
Stop T | (Inherited from Entity.) | |
ToString | (Inherited from Entity.) | |
Update | (Inherited from Trigger.) |
Fields
Name | Description | |
---|---|---|
components | (Inherited from Entity.) | |
Invoked | (Inherited from Trigger.) |
Properties
Name | Description | |
---|---|---|
Elapsed | ||
HoldArea | ||
HoldTime | ||
IsActive | (Inherited from Entity.) | |
IsPauseable | (Inherited from Trigger.) | |
Movement | ||
NumberOfComponents | (Inherited from Entity.) | |
UpdatePriority | (Inherited from Entity.) | |
WasInvokedThisTick | (Inherited from Trigger.) |
Remarks
Examples
[Test] public void HoldOnRectangle() { var drawArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.25f); new FilledRect(drawArea, Color.Blue); var trigger = new TouchHoldTrigger(drawArea); var counter = 0; var text = new FontText(Font.Default, "", drawArea.Move(new Vector2D(0.0f, 0.25f))); new Command(() => text.Text = "TouchHold Triggered " + ++counter + " times.").Add(trigger); }
[Test, CloseAfterFirstFrame] public void Create() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.5f); Assert.AreEqual(Rectangle.One, trigger.HoldArea); Assert.AreEqual(0.5f, trigger.HoldTime); }
[Test, CloseAfterFirstFrame] public void CreateFromAttributes() { var trigger = new TouchHoldTrigger(new Dictionary<string, string> { { "HoldArea", "0.1, 0.2, 0.3, 0.4" }, { "HoldTime", "10.4" } }); Assert.AreEqual(new Rectangle(0.1f, 0.2f, 0.3f, 0.4f), trigger.HoldArea); Assert.AreEqual(10.4f, trigger.HoldTime); } [Test, CloseAfterFirstFrame] public void IsHovering() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.5f); Assert.IsFalse(trigger.IsHovering()); trigger.Elapsed = 1f; Assert.IsFalse(trigger.IsHovering()); } [Test, CloseAfterFirstFrame] public void PessingInTheSamePositionWillMakeTriggerHover() { var trigger = new TouchHoldTrigger(Rectangle.One, 0.0001f); new Command(() => { }).Add(trigger); SetTouchState(State.Pressing, Vector2D.Half); SetTouchState(State.Pressed, Vector2D.Half); SetTouchState(State.Releasing, Vector2D.Half); Assert.IsTrue(trigger.IsHovering()); } private void SetTouchState(State state, Vector2D position) { if (touch == null) return; //ncrunch: no coverage touch.SetTouchState(0, state, position); AdvanceTimeAndUpdateEntities(); } }
See Also