Drag and Drop events triggered by mouse input from the user.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Entities Entity
DeltaEngine.Commands Trigger
DeltaEngine.Commands InputTrigger
DeltaEngine.Input MouseDragDropTrigger
Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The MouseDragDropTrigger type exposes the following members.
Constructors
Name | Description | |
---|---|---|
MouseDragDropTrigger(Dictionary String, String ) | Initializes a new instance of the MouseDragDropTrigger class | |
MouseDragDropTrigger(Rectangle, MouseButton) | Initializes a new instance of the MouseDragDropTrigger 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 | |
---|---|---|
Button | ||
IsActive | (Inherited from Entity.) | |
IsPauseable | (Inherited from Trigger.) | |
NumberOfComponents | (Inherited from Entity.) | |
StartArea | ||
StartDragPosition | ||
UpdatePriority | (Inherited from Entity.) | |
WasInvokedThisTick | (Inherited from Trigger.) |
Remarks
Examples
[Test, CloseAfterFirstFrame] public void Create() { var trigger = new MouseDragDropTrigger(Rectangle.One, MouseButton.Right); Assert.AreEqual(Rectangle.One, trigger.StartArea); Assert.AreEqual(MouseButton.Right, trigger.Button); Assert.AreEqual(Vector2D.Unused, trigger.StartDragPosition); }
[Test, CloseAfterFirstFrame] public void CreateFromAttributes() { var trigger = new MouseDragDropTrigger(new Dictionary<string, string> { { "StartArea", "1.1 2.2 3.3 4.4" }, { "Button", "Right" } }); Assert.AreEqual(new Rectangle(1.1f, 2.2f, 3.3f, 4.4f), trigger.StartArea); Assert.AreEqual(MouseButton.Right, trigger.Button); Assert.AreEqual(Vector2D.Unused, trigger.StartDragPosition); Assert.Throws<MouseDragDropTrigger.CannotCreateMouseDragDropTriggerWithoutStartArea>( () => new MouseDragDropTrigger(new Dictionary<string, string>())); } [Test, CloseAfterFirstFrame] public void DragDropOutsideStartArea() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Zero); SetMouseState(State.Pressed, Vector2D.One); SetMouseState(State.Releasing, Vector2D.One); SetMouseState(State.Released, Vector2D.One); Assert.AreEqual(-Vector2D.One, startPoint); } private void SetMouseState(State state, Vector2D position) { if (mouse == null) return; //ncrunch: no coverage mouse.SetButtonState(MouseButton.Left, state); mouse.SetNativePosition(position); AdvanceTimeAndUpdateEntities(); } [Test, CloseAfterFirstFrame] public void DragDropInsideStartArea() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Half); SetMouseState(State.Pressed, Vector2D.One); SetMouseState(State.Releasing, Vector2D.One); Assert.AreEqual(Vector2D.Half, startPoint); } [Test, CloseAfterFirstFrame] public void DragDropCloseToStartPointWillDoNothing() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Half); SetMouseState(State.Pressed, Vector2D.Half); SetMouseState(State.Releasing, Vector2D.Half); Assert.AreEqual(-Vector2D.One, startPoint); } }
[Test, CloseAfterFirstFrame] public void DragDropOutsideStartArea() { if (mouse == null) return; //ncrunch: no coverage Vector2D startPoint = -Vector2D.One; new Command(position => { startPoint = position; }).Add( new MouseDragDropTrigger(Rectangle.HalfCentered, MouseButton.Left)); SetMouseState(State.Pressing, Vector2D.Zero); SetMouseState(State.Pressed, Vector2D.One); SetMouseState(State.Releasing, Vector2D.One); SetMouseState(State.Released, Vector2D.One); Assert.AreEqual(-Vector2D.One, startPoint); }
See Also