NUnitForms Class Library

MouseController.Press Method (Keys)

Simulate pressing the mouse modifier key(s) (Alt, Shift and Control).

[Visual Basic]
Overloads Public Sub Press( _
   ByVal keys As Keys _
)
[C#]
public void Press(
   Keys keys
);

Parameters

keys
A bitwise combination of the Keys enumeration values. Only Alt, Shift and Control are allowed.

Remarks

Press simulates pressing the specified keys.

Exceptions

Exception TypeCondition
ArgumentOutOfRangeException When keys contains a value that is not Alt, Shift or Control.

Example

The following example performs a "shift drag" and verifies that two objects are selected.

            [TestFixture] public class ATest : NUnitFormTest
            {
              // Gets the Form used for testing.
              public override Type FormType
              {
                get {return typeof(MyTestForm);}
              }
              
              [Test] public void Selecting()
              {
                ControlTester myControl = new ControlTester("myControl", CurrentForm);
                using (MouseController mouse = myControl.MouseController())
                {
                  mouse.Drag (10,10, 20,20);
                  AssertEquals (1, myControl.Properties.SelectedObjects.Count);
                  
                  mouse.Press(Keys.Shift);
                  mouse.Drag(100,100, 200,200);
                  mouse.Release(Keys.Shift);
                  AssertEquals (2, myControl.Properties.SelectedObjects.Count);
                }
              }
             

See Also

MouseController Class | NUnit.Extensions.Forms Namespace | MouseController.Press Overload List