Fires once when the mouse has not moved for a prescribed period. Ideally used in tandem with
MouseMovementTrigger to cancel the logic raised on a hover.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Entities Entity
DeltaEngine.Commands Trigger
DeltaEngine.Commands InputTrigger
DeltaEngine.Input MouseHoverTrigger
Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The MouseHoverTrigger type exposes the following members.
Constructors
Name | Description | |
---|---|---|
MouseHoverTrigger(Dictionary String, String ) | Initializes a new instance of the MouseHoverTrigger class | |
MouseHoverTrigger(Single) | Initializes a new instance of the MouseHoverTrigger 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.) | |
HandleWithMouse | ||
Invoke | (Inherited from Trigger.) | |
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 | ||
HoverTime | ||
IsActive | (Inherited from Entity.) | |
IsPauseable | (Inherited from Trigger.) | |
LastPosition | ||
NumberOfComponents | (Inherited from Entity.) | |
UpdatePriority | (Inherited from Entity.) | |
WasInvokedThisTick | (Inherited from Trigger.) |
Remarks
Examples
[Test] public void CountdownOnMouseHover() { var trigger = new MouseHoverTrigger(3.0f); new Countdown(new FontText(Font.Default, "", Rectangle.One), trigger); var drawArea = Rectangle.One; var counter = 0; var text = new FontText(Font.Default, "", drawArea.Move(new Vector2D(0.0f, 0.1f))); new Command(() => text.Text = "MouseHover triggered " + ++counter + " times.").Add(trigger); }
[Test, CloseAfterFirstFrame] public void HoverTriggersIfMouseDoesntMove() { bool isTriggered = false; new Command(() => isTriggered = true).Add(new MouseHoverTrigger()); Resolve<Mouse>().SetNativePosition(Vector2D.Zero); AdvanceTimeAndUpdateEntities(1.0f); Assert.IsFalse(isTriggered); AdvanceTimeAndUpdateEntities(1.0f); Assert.IsTrue(isTriggered); }
[Test, CloseAfterFirstFrame] public void HoverDoesntTriggersIfMouseMoves() { bool isTriggered = false; new Command(() => isTriggered = true).Add(new MouseHoverTrigger()); Resolve<Mouse>().SetNativePosition(Vector2D.Zero); AdvanceTimeAndUpdateEntities(0.5f); Resolve<Mouse>().SetNativePosition(Vector2D.One); AdvanceTimeAndUpdateEntities(0.5f); Assert.IsFalse(isTriggered); }
See Also