InkEdit.Gesture Event

InkEdit.Gesture Event

Occurs when an application-specific gesture is recognized.

Definition

Visual Basic .NET Public Event Gesture As InkEditGestureEventHandler
C# public event InkEditGestureEventHandler Gesture;
Managed C++ public: __event InkEditGestureEventHandler Gesture;

Remarks

Application gestures are defined as gestures that are supported within your application.

For this event to occur, the InkEdit control must have interest in a set of application gestures. To set the InkEdit's interest in a set of gestures, call the SetGestureStatus method.

For a list of specific application gestures, see the ApplicationGesture enumeration type. For more information about application gestures, see Making Windows Work with a Pen.

The event handler receives an argument of type InkEditGestureEventArgs that contains data about this event.

When you create an InkEditGestureEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.

In the InkEdit control, a Gesture event is raised only if the gesture is the first stroke since the last call to the Recognize method or the last firing of the recognition timeout.

If the Gesture event is cancelled, the Stroke event is raised for the strokes that raised the Gesture event.

The Gesture event is only raised for gestures that the InkEdit control has an interest in. Use the InkEdit control's SetGestureStatus method to change the gestures that the control is interested in. The InkEdit control does not recognize multiple stroke gestures.

The InkEdit control has default interest in and actions for the following gestures.

Gesture Action
Down-left, Down-left-long Enter
Right Space
Left Backspace
Up-right, Up-right-long Tab

To alter the default action for a gesture

  • Add event handlers for the Gesture and Stroke events.
  • In the Gesture event handler, cancel the Gesture event for the gesture, and perform the alternate action for the gesture.
  • In the Stroke event handler, cancel the Stroke event for the stroke that raised the cancelled Gesture event.

Examples

[C#]

This C# example demonstrates how to alter the default action for the "Right" application gesture by capturing and canceling both a Gesture and Stroke event.

private int theStrokeID;
//...
private void inkEdit1_Gesture(object sender,
  Microsoft.Ink.InkEditGestureEventArgs e)
{
  if (e.Gestures[0].Id == ApplicationGesture.Right)
  {
    theStrokeID = e.Strokes[0].Id;
    e.Cancel = true;
  }
}

private void inkEdit1_Stroke(object sender, Microsoft.Ink.InkEditStrokeEventArgs e)
{
  if (e.Stroke.Id == theStrokeID)
  {
    System.Diagnostics.Debug.WriteLine("Right-Gesture recognized");
    e.Cancel = true;
  }
}

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example demonstrates how to alter the default action for the "Right" application gesture by capturing and canceling both a Gesture and Stroke event.

Private theStrokeID As Integer
//...
Private Sub InkEdit1_Gesture(ByVal sender As Object, ByVal e As Microsoft.Ink.InkEditGestureEventArgs)
Handles InkEdit1.Gesture
    If e.Gestures(0).Id = ApplicationGesture.Right Then
        theStrokeID = e.Strokes(0).Id
        e.Cancel = True
    End If
End Sub

Private Sub InkEdit1_Stroke(ByVal sender As Object, ByVal e As Microsoft.Ink.InkEditStrokeEventArgs)
Handles InkEdit1.Stroke
    If e.Stroke.Id = theStrokeID Then
        System.Diagnostics.Debug.WriteLine("Right-Gesture recognized")
        e.Cancel = True
    End If
End Sub

See Also