[]
        
(Showing Draft Content)

Detecting Touch

You can detect Tap, Double-Tap and Right-Tap by using the C1TouchEventProvider. To detect Hold instead of Right-Tap, see Detecting Tap and Hold (Long-Tap).


The following steps indicates how to detect Click by Mouse or Tap by Touch.

  1. Add a Button control to the Form. (Button1).

  2. Add a C1TouchEventProvider to the Form. (C1TouchEventProvider1).

  3. Select the Button1, Set "EnableTouchEvents of C1TouchEventProvider1" property to True in the Property Window.

  4. Select the Button1, Add the following code to its Click event.

  5. Select the C1TouchEventProvider1, Add the following code to its Tapped event.

[C#]

using C1.Win.TouchToolKit;

private void Form1_Load(object sender, EventArgs e)
{
  c1TouchEventProvider1.SetEnableTouchEvents(this.button1, true);
  c1TouchEventProvider1.Tapped += c1TouchEventProvider1_Tapped;
  button1.Click += button1_Click;
}

private void c1TouchEventProvider1_Tapped(object sender, TappedEventArgs e)
{
  if (e.TargetControl == button1)
  {
    MessageBox.Show("Pressed by Touch");
  }
}

private void button1_Click(object sender, EventArgs e)
{
  MessageBox.Show("Pressed by Mouse");
}

[Visual Basic]

Imports C1.Win.TouchToolKit

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  C1TouchEventProvider1.SetEnableTouchEvents(Button1, True)
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  MessageBox.Show("Pressed by Mouse")
End Sub

Private Sub C1TouchEventProvider1_Tapped(sender As System.Object, e As C1.Win.TouchToolKit.TappedEventArgs) Handles C1TouchEventProvider1.Tapped
  MessageBox.Show("Pressed by Touch")
End Sub
  1. Run the project, and Click or Tap Button1.