Handling Multitouch in the Canvas Widget

Post your Lemur Projects.
Post Reply
midikinetics
Regular
Posts: 59
Joined: 15 May 2015 17:46
Contact:

Handling Multitouch in the Canvas Widget

Post by midikinetics »

When a Canvas is set to multitouch, your scripts can receive input from multiple simultaneous touch points, each identified by a unique cursor ID. This makes it possible to implement advanced two-handed controls or gestures that track each finger independently. Canvas doesn't impose any specific gesture system — it's up to you to define the behavior you want.

The basic idea is to track the state of each active touch:
  • On Cursor Down, record the cursor ID and its coordinates.
  • On Cursor Move, update those coordinates.
  • On Cursor Up, clear out the data associated with that cursor.
To do this, you typically use parallel arrays (or vectors) to store:
  • * Active cursor IDs
  • * Corresponding X and Y positions
This allows the object to maintain internal state across touches, so your scripts can determine how many touches are active, where they are, and what kind of interaction is occurring. For example, you might trigger a different behavior when two fingers are detected in a region versus just one.

A new example project, MultitouchCanvas.jzml, demonstrating this approach is now available in the Example Lemur Projects GitHub repository. It shows a minimal working setup that tracks multiple touches and displays the number of active cursors.

https://github.com/MIDIKinetics/ExampleLemurProjects
Phil999
Regular
Posts: 945
Joined: 11 Jan 2012 01:53

Re: Handling Multitouch in the Canvas Widget

Post by Phil999 »

many thanks.
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
Post Reply