HTP Events
Events - Concepts
The HTP API Toolkit offers a wide variety of events that users can take advantage of. However, the most important aspect to consider is the adaptation of the surface events Contact Down, Changed and Up. For users unfamiliar with such events, they work similar to the mouse events supported in WPF. We also provide event arguments in which more information can be accessed regarding the HTP.
The event arguments include:
- Current HTP - returns the HTP triggering the event.
- Center Point - returns the center point of the HTP.
- End Point - Returns the end point of the HTP if an offset has been set.
- Friction - Returns the current friction value of the HTP.
- Height - Returns the current height value of the HTP.
- ID - Returns the ID that corresponds to the HTP (the marker tag).
- Orientation - Returns the orientation of the HTP.
- Pressure - Returns the pressure value of the HTP.
Programming with Events
Event programming is simple and it's done independently for each HTP (although multiple HTPs can be associated to a particular event).
Please note that the HTP contact events covered here are only available when working in the medium and high levels.
Example
In this example we create a basic application in which a behavior's parameter changes depending on the location of an HTP.
- HTPManager manager = HTPManager.Instance;
- IntensityBehavior intensity;
- public HTPWindow()
- {
- InitializeComponent();
- // Add handlers for Application activation events
- AddActivationHandlers();
- // Default Window Registration
- this.manager.RegisterWindow(this, this.HTPCanvas);
- // HTP 0xB8 will test the medium level
- HTP h1 = this.manager.GetHTP(0xB8);
- h1.AddHeightBehavior(intensity);
- h1.WidgetWeight = 0.0;
- }
- void h1_HTPChanged(object sender, HTPEventArgs e)
- {
- this.intensity.Intensity = (e.CenterPoint.X / 1024.0);
- }