Share via


InkPicture.CursorDown Event

Occurs when the cursor tip contacts the digitizing tablet surface.

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Event CursorDown As InkCollectorCursorDownEventHandler
'Usage
Dim instance As InkPicture
Dim handler As InkCollectorCursorDownEventHandler

AddHandler instance.CursorDown, handler
public event InkCollectorCursorDownEventHandler CursorDown
public:
event InkCollectorCursorDownEventHandler^ CursorDown {
    void add (InkCollectorCursorDownEventHandler^ value);
    void remove (InkCollectorCursorDownEventHandler^ value);
}
/** @event */
public void add_CursorDown (InkCollectorCursorDownEventHandler value)

/** @event */
public void remove_CursorDown (InkCollectorCursorDownEventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

Remarks

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

When you create a InkCollectorCursorDownEventHandler delegate, you identify the method that handles 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. For performance reasons, the default event interest is off but is turned on automatically if you add an event handler.

This event may have an adverse effect on ink performance if too much code is executed in the event handlers. To improve real-time ink performance, hide the mouse cursor while inking. To do so, hide the mouse cursor in the MouseDown event handler, and show the mouse cursor in the MouseUp event handler.

Example

This C# example uses several event handlers to display the state of the Cursor objects, CursorButton objects, and Tablet objects. The application has a status bar with three panels—sbPanelCursor, sbPanelButton, and sbPanelTablet—in which messages appear when events are received.

[C#]

//...
using Microsoft.Ink;
//...
    public class Form1 : System.Windows.Forms.Form
    {
        private Microsoft.Ink.InkPicture theInkPicture;
        private System.Windows.Forms.StatusBar statusBar1;
        private System.Windows.Forms.StatusBarPanel sbPanelCursor;
        private System.Windows.Forms.StatusBarPanel sbPanelButton;
        private System.Windows.Forms.StatusBarPanel sbPanelTablet;
//...

        public Form1()
        {
            //...
            // Add event handlers for cursor and button events.
            theInkPicture.CursorButtonUp += new InkCollectorCursorButtonUpEventHandler(CursorButtonUp_Event);
            theInkPicture.CursorButtonDown += new InkCollectorCursorButtonDownEventHandler(CursorButtonDown_Event);
            theInkPicture.CursorOutOfRange += new InkCollectorCursorOutOfRangeEventHandler(CursorOutOfRange_Event);
            theInkPicture.CursorInRange += new InkCollectorCursorInRangeEventHandler(CursorInRange_Event);
            theInkPicture.CursorDown += new InkCollectorCursorDownEventHandler(CursorDown_Event);
            theInkPicture.TabletAdded += new InkCollectorTabletAddedEventHandler(TabletAdded_Event);
            theInkPicture.TabletRemoved += new InkCollectorTabletRemovedEventHandler(TabletRemoved_Event);
        }

//...

        private void CursorButtonUp_Event(object sender, InkCollectorCursorButtonUpEventArgs e)
        {
            sbPanelButton.Text = e.Button.Name + " Button Up";
        }

        private void CursorButtonDown_Event(object sender, InkCollectorCursorButtonDownEventArgs e)
        {
            sbPanelButton.Text = e.Button.Name + " Button Down";
        }

        private void CursorOutOfRange_Event(object sender, InkCollectorCursorOutOfRangeEventArgs e)
        {
            sbPanelCursor.Text = e.Cursor.Name + " Out of Range";
        }

        private void CursorInRange_Event(object sender, InkCollectorCursorInRangeEventArgs e)
        {
            sbPanelCursor.Text = e.Cursor.Name + " In Range";
        }

        private void CursorDown_Event(object sender, InkCollectorCursorDownEventArgs e)
        {
            sbPanelCursor.Text = e.Cursor.Name + " Down";
        }

        private void TabletAdded_Event(object sender, InkCollectorTabletAddedEventArgs e)
        {
            sbPanelTablet.Text = "Tablet added: " + e.Tablet.Name;
        }

        private void TabletRemoved_Event(object sender, InkCollectorTabletRemovedEventArgs e)
        {
            sbPanelTablet.Text = "Tablet removed: " + e.TabletId;
        }
//...

This Microsoft® Visual Basic® .NET example uses several event handlers to display the state of the Cursor objects, CursorButton objects, and Tablet objects. The application has a status bar with three panels—sbPanelCursor, sbPanelButton, and sbPanelTablet—in which messages appear when events are received.

[Visual Basic]

Imports Microsoft.Ink
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        AddHandler theInkPicture.CursorButtonUp, AddressOf CursorButtonUp_Event
        AddHandler theInkPicture.CursorButtonDown, AddressOf CursorButtonDown_Event
        AddHandler theInkPicture.CursorOutOfRange, AddressOf CursorOutOfRange_Event
        AddHandler theInkPicture.CursorInRange, AddressOf CursorInRange_Event
        AddHandler theInkPicture.CursorDown, AddressOf CursorDown_Event
        AddHandler theInkPicture.TabletAdded, AddressOf TabletAdded_Event
        AddHandler theInkPicture.TabletRemoved, AddressOf TabletRemoved_Event

    End Sub

'...

    Friend theInkPicture WithEvents theInkPicture As Microsoft.Ink.InkPicture

'...

#End Region

    Private Sub CursorButtonUp_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorButtonUpEventArgs)
        sbPanelButton.Text = e.Button.Name + " Button Up"
    End Sub

    Private Sub CursorButtonDown_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorButtonDownEventArgs)
        sbPanelButton.Text = e.Button.Name + " Button Down"
    End Sub

    Private Sub CursorOutOfRange_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorOutOfRangeEventArgs)
        sbPanelCursor.Text = e.Cursor.Name + " Out of Range"
    End Sub

    Private Sub CursorInRange_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorInRangeEventArgs)
        sbPanelCursor.Text = e.Cursor.Name + " In Range"
    End Sub

    Private Sub CursorDown_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorCursorDownEventArgs)
        sbPanelCursor.Text = e.Cursor.Name + " Down"
    End Sub

    Private Sub TabletAdded_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorTabletAddedEventArgs)
        sbPanelTablet.Text = "Tablet Added: " + e.Tablet.Name
    End Sub

    Private Sub TabletRemoved_Event( _
        ByVal sender As Object, _
        ByVal e As InkCollectorTabletRemovedEventArgs)
        sbPanelTablet.Text = "Tablet Removed: " + e.TabletId
    End Sub

End Class

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkPicture Class
InkPicture Members
Microsoft.Ink Namespace
Cursor
InkCollectorCursorDownEventArgs
InkCollectorCursorDownEventHandler
InkPicture.OnCursorDown
Tablet