Share via


Gesture Event

Gesture Event

Occurs when an application-specific gesture is recognized.

Declaration

[C++]

void Gesture(
    [in] IInkCursor* Cursor,
    [in] IInkStrokes* Strokes,
    [in] VARIANT Gestures,
    [in, out] VARIANT_BOOL* Cancel
);

[Microsoft® Visual Basic® 6.0]

Public Event Gesture( _
    Cursor As IInkCursor, _
    Strokes As InkStrokes, _
    Gestures, _
    Cancel As Boolean _
)

Parameters

Cursor

[in] The IInkCursor object that generated the Gesture event.

Strokes

[in] The IInkStrokes collection that the recognizer returned as the gesture.

Gestures

[in] An array of IInkGesture objects, in order of confidence, from the recognizer.

For more information about the VARIANT structure, see Using the Automation Library.

Cancel

[in, out] Whether the collection of this gesture should be canceled, such as not to erase the ink and to fire the Stroke event.

Remarks

This event method is defined in the _IInkCollectorEvents, _IInkOverlayEvents, and _IInkPictureEvents dispatch-only interfaces (dispinterfaces) with an ID of DISPID_ICEGesture.

When the CollectionMode property is set to GestureOnly, the timeout between when a user adds a gesture and when the Gesture event occurs is a fixed value that you cannot alter programmatically. Gesture recognition is faster in InkAndGesture mode.

To prevent the collection of ink while in InkAndGesture mode:

To prevent the flow of ink while gesturing, set DynamicRendering property to FALSE.

In addition to when inserting ink, the Gesture event is fired when in select or erase mode. You are responsible for tracking the editing mode and should be aware of the mode before interpreting the event.

Note: To recognize gestures, you must use an object or control that can collect ink.

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

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

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

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example displays application and system gesture event information in a multiline text edit control, Text1, on the main form window.

Option Explicit
Dim WithEvents theInkCollector As InkCollector

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    'Set the ink collection mode to collect ink and gestures,
    'and turn off all application gestures except the chevrons.
    theInkCollector.CollectionMode = ICM_InkAndGesture
    theInkCollector.SetGestureStatus IAG_AllGestures, False
    theInkCollector.SetGestureStatus IAG_ChevronUp, True
    theInkCollector.SetGestureStatus IAG_ChevronDown, True
    theInkCollector.SetGestureStatus IAG_ChevronLeft, True
    theInkCollector.SetGestureStatus IAG_ChevronRight, True
    theInkCollector.Enabled = True
    theInkCollector.SetEventInterest ICEI_SystemGesture, True
End Sub

Private Sub theInkCollector_Gesture( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Strokes As MSINKAUTLib.InkStrokes, _
ByVal Gestures As Variant, _
Cancel As Boolean)
    Dim theGesture As Variant
    Dim X As Long
    Dim Y As Long
    Text1.Text = ""
    For Each theGesture In Gestures
        theGesture.GetHotPoint X, Y
        Text1.Text = Text1.Text & "Gesture " & _
        AppGestureName(theGesture.Id) & _
        " at (" & X & "," & Y & ") confidence: " & _
        ConfidenceName(theGesture.Confidence) & vbCrLf
    Next
End Sub

Private Sub theInkCollector_SystemGesture( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Id As MSINKAUTLib.InkSystemGesture, _
ByVal X As Long, ByVal Y As Long, _
ByVal Modifier As Long, _
ByVal Character As String, _
ByVal CursorMode As Long)
    Text1.Text = "SystemGesture " & _
    SystemGestureName(Id) & " (x:" & X & ",y:" & Y & ")"
End Sub

Private Function SystemGestureName(ByVal Id As InkSystemGesture) As String
    Select Case Id
        Case ISG_DoubleTap
            SystemGestureName = "ISG_DoubleTap"
        Case ISG_Drag
            SystemGestureName = "ISG_Drag"
        Case ISG_HoldEnter
            SystemGestureName = "ISG_HoldEnter"
        Case ISG_HoldLeave
            SystemGestureName = "ISG_HoldLeave"
        Case ISG_HoverEnter
            SystemGestureName = "ISG_HoverEnter"
        Case ISG_HoverLeave
            SystemGestureName = "ISG_HoverLeave"
        Case ISG_RightDrag
            SystemGestureName = "ISG_RightDrag"
        Case ISG_RightTap
            SystemGestureName = "ISG_RightTap"
        Case ISG_Tap
            SystemGestureName = "ISG_Tap"
        Case Else
            SystemGestureName = "SystemGesture(" & Id & ")"
    End Select
End Function

Private Function AppGestureName(ByVal Id As InkApplicationGesture) _
As String
    Select Case Id
        Case IAG_AllGestures
            AppGestureName = "IAG_AllGestures"
        Case IAG_NoGesture
            AppGestureName = "IAG_NoGesture"
        Case IAG_ChevronUp
            AppGestureName = "IAG_ChevronUp"
        Case IAG_ChevronDown
            AppGestureName = "IAG_ChevronDown"
        Case IAG_ChevronLeft
            AppGestureName = "IAG_ChevronLeft"
        Case IAG_ChevronRight
            AppGestureName = "IAG_ChevronRight"
        Case Else
            AppGestureName = "AppGesture(" & Id & ")"
    End Select
End Function

Private Function ConfidenceName(ByVal Id As InkRecognitionConfidence) _
As String
    Select Case Id
        Case IRC_Strong
            ConfidenceName = "IRC_Strong"
        Case IRC_Intermediate
            ConfidenceName = "IRC_Intermediate"
        Case IRC_Poor
            ConfidenceName = "IRC_Poor"
        Case Else
            ConfidenceName = "Confidence(" & Id & ")"
    End Select
End Function

Applies To