Page 1 of 1

canvas_addHitRegion question

Posted: 21 Oct 2014 18:29
by Phil999
I try to understand how canvas_addHitRegion(c, path, id) works. In the attachment I have two examples of this command. One is working, but it has no path. The other one is not working (red script) and has a path.

- what is the name of the path if one is present (other than the default path)?
- what is the identifier?

In the Hexapads example the path is set to 0, but the identifier to a mathematical expression. Can somebody shed some light on this matter? I'm completely in the dark.

What I want is very simple: a custom button with transparent corners. What I can do is to use the brown canvas as background and put the transparent canvas on top of it, problem solved. But I prefer to understand how the hit region works, and integrate it into one Canvas object.
hitRegion.jzml
(2.92 KiB) Downloaded 54 times
Edit: alright, I found (rather by accident) a solution. When I put the HitRegion-line (still with 0 for path and id) into the 'draw' script I can do things inside the 'touch' script. It works. In the Hexapads template the id is declared (decl ...) before the HitRegion-line. Maybe one has to declare the identifier for a HitRegion? Yeah I admit I haven't quite understood how it works, but at least I've made a little step further with that problem solved.

Edit2: oh no, in the "touch"-script I was referencing "c" which was not declared (in that script). Of course the script will be in red. Silly mistake, sorry about that. Although obsolete now I don't delete this thread because there might be someone who can give me more insight into the nature of using the hit region, or I may add some tips later when I found them out.

Re: canvas_addHitRegion question

Posted: 23 Oct 2014 02:46
by Macciza
Have you gone through the examples in the CanvasLearningPackage? They may help...

Path is often 0 in loops because it is referring to Path just made...
ID has to vary if you want the paths individually identified ...
The various OnCursor functions return the ID in the hit variable ...

Hope that helps

Re: canvas_addHitRegion question

Posted: 27 Oct 2014 08:52
by Softcore
Not sure why you need hit regions for a single button....I guess you would need them though for multiple buttons designed with one canvas.....

here is how far I've went (without hit regions)......

colors and radius of corners (r) are set with custom expressions so that you can easily change them. Midi output is named "out"

Re: canvas_addHitRegion question

Posted: 27 Oct 2014 08:57
by Softcore
And here is the Pad version (push button, momentary button)