Share via


InkEdit.Gesture (Evento)

Actualización: noviembre 2007

Se produce cuando se reconoce un movimiento de aplicación.

Espacio de nombres:  Microsoft.Ink
Ensamblado:  Microsoft.Ink (en Microsoft.Ink.dll)

Sintaxis

'Declaración
Public Event Gesture As InkEditGestureEventHandler
'Uso
Dim instance As InkEdit
Dim handler As InkEditGestureEventHandler

AddHandler instance.Gesture, handler
public event InkEditGestureEventHandler Gesture
public:
 event InkEditGestureEventHandler^ Gesture {
    void add (InkEditGestureEventHandler^ value);
    void remove (InkEditGestureEventHandler^ value);
}
/** @event */
public void add_Gesture (InkEditGestureEventHandler value)
/** @event */
public void remove_Gesture (InkEditGestureEventHandler value)
JScript no admite eventos.

Comentarios

El controlador de eventos recibe un argumento de tipo InkEditGestureEventArgs que contiene datos sobre este evento.

Al crear un delegado de InkEditGestureEventHandler, se identifica el método que controla el evento. Para asociarlo al controlador de eventos, se debe agregar al evento una instancia del delegado. Siempre que se produce el evento, se llama a su controlador, a menos que se quite el delegado.

Para que este evento se produzca, el control InkEdit debe tener interés en un conjunto de movimientos de aplicación. Para establecer el interés del control InkEdit en un conjunto de movimientos, llame al método InkEdit.SetGestureStatus. El control InkEdit no reconoce los movimientos de trazos múltiples.

Para obtener una lista de los movimientos específicos de una aplicación, vea el tipo de enumeración ApplicationGesture. Para obtener más información acerca de los movimientos de una aplicación, vea Using Gestures y Command Input on the Tablet PC.

De manera predeterminada, el control InkEdit tiene el interés en los siguientes movimientos y ejecuta las siguientes acciones en respuesta a los mismos.

Movimiento

Acción

Down-left, Down-left-long

Entrar

Right

Espacio

Left

Retroceso

Up-right, Up-right-long

Tabulador

En el control InkEdit, únicamente se provoca un evento Gesture si el movimiento es el primer trazo desde la última llamada al método Recognize o el último desencadenamiento del tiempo de espera del reconocimiento.

Si el evento Gesture se cancela, se provoca el evento Stroke para los objetos Stroke que provocaron el evento Gesture.

Para modificar la acción predeterminada de un movimiento

  • Agregue los controladores de eventos para los eventos Stroke y Gesture.

  • En el controlador de eventos Gesture, cancele el evento Gesture del movimiento y lleve a cabo la acción alternativa para el mismo.

  • En el controlador de eventos Stroke, cancele el evento Stroke para el objeto Stroke que provocó el evento Gesture cancelado.

Ejemplos

En este ejemplo se muestra cómo puede suscribirse al evento Gesture y al evento Stroke para aumentar la funcionalidad de un objeto ApplicationGesture.

Cuando se activa el evento Gesture, se examina el movimiento y el estado actual del control InkEdit. Si es necesario, se modifica el comportamiento del movimiento y se cancela el evento.

Private Sub mInkEdit_Gesture(ByVal sender As Object, ByVal e As InkEditGestureEventArgs)
    ' There might be more than one gesture passed in InkEditGestureEventArgs
    ' The gestures are arranged in order of confidence from most to least
    ' This event handler is only concerned with the first (most confident) gesture
    ' and only if the gesture is ApplicationGesture.Left with strong confidence
    Dim G As Gesture = e.Gestures(0)
    If (ApplicationGesture.Left = G.Id And RecognitionConfidence.Strong = G.Confidence) Then
        Dim pInkEdit As InkEdit = DirectCast(sender, InkEdit)
        ' by default, ApplicationGesture.Left maps to Backspace
        ' If the insertion point is at the beginning of the text
        ' and there is no text selected, then Backspace does not do anything.
        ' In this case, we will alter the gesture to map to Delete instead
        If (0 = pInkEdit.SelectionStart And 0 = pInkEdit.SelectionLength And pInkEdit.Text.Length > 0) Then
            ' take out the first character of the string
            pInkEdit.Text = pInkEdit.Text.Remove(0, 1)
            ' save the stroke ID in a class level var for use in the Stroke event
            Me.mStrokeID = e.Strokes(0).Id
            ' cancel the gesture so it won't perform the default action
            e.Cancel = True
        End If
    End If
End Sub
private void mInkEdit_Gesture(object sender, InkEditGestureEventArgs e)
{
    // There might be more than one gesture passed in InkEditGestureEventArgs
    // The gestures are arranged in order of confidence from most to least
    // This event handler is only concerned with the first (most confident) gesture
    // and only if the gesture is ApplicationGesture.Left with strong confidence
    Gesture G = e.Gestures[0];
    if (ApplicationGesture.Left == G.Id &&  RecognitionConfidence.Strong == G.Confidence)
    {
        InkEdit pInkEdit = (InkEdit)sender;

        // by default, ApplicationGesture.Left maps to Backspace
        // If the insertion point is at the beginning of the text
        // and there is no text selected, then Backspace does not do anything.
        // In this case, we will alter the gesture to map to Delete instead
        if (0 == pInkEdit.SelectionStart && 0 == pInkEdit.SelectionLength && pInkEdit.Text.Length > 0)
        {
            // take out the first character of the string
            pInkEdit.Text = pInkEdit.Text.Remove(0, 1);
            // save the stroke ID in a class level var for use in the Stroke event
            this.mStrokeID = e.Strokes[0].Id;
            // cancel the gesture so it won't perform the default action
            e.Cancel = true;
        }
    }
}

Cuando se activa el evento Stroke, éste se cancela si el trazo es el que se usó para generar el movimiento cuyo comportamiento se modificó en el evento Gesture. De este modo, se impide la representación del trazo.

Private Sub mInkEdit_Stroke(ByVal sender As Object, ByVal e As InkEditStrokeEventArgs)
    e.Cancel = (e.Stroke.Id = Me.mStrokeID)
End Sub
private void mInkEdit_Stroke(object sender, InkEditStrokeEventArgs e)
{
    e.Cancel = (e.Stroke.Id == this.mStrokeID);
}

Plataformas

Windows Vista

.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Información de versión

.NET Framework

Compatible con: 3.0

Vea también

Referencia

InkEdit (Clase)

InkEdit (Miembros)

Microsoft.Ink (Espacio de nombres)

InkEditGestureEventArgs

ApplicationGesture

InkEdit.SetGestureStatus

InkEdit.RecoTimeout