DrawablePath Mouselistener?

Hi,

I have what you might call a typical daw Automation UI consisting of a DrawablePath which you can add nodes to and manipulate curves etc.

It works well, however at this stage i can only add nodes by making the parent component accept mouse events, which obviously isnt ideal if you want to manipulate the clips beneath.

What i would like is to be able to click on the DrawablePath to select it to be editable, add nodes etc

Nothing i do with mouse listeners seems to have any effect, perhaps because there are no bounds set? And I also investigated trying to detect line intersection with the mouse coordinates, but the docs state that this only works with closed paths.

So, is it possible to get a drawable path to detect the mouse?

Have a look at the Component::hitTest() method.

A DrawablePath is a component, but I don't recommend inheriting from it, better to use your own custom comp.

Ah yes, thanks that works great.

I have overriden hittest in the parent component and am checking the mouse proximity by using getNearestPoint.

I originially tried using getPointAlongPath, however i soon realised this is the length of the path not the pixel position.

When it comes to applying the automation value to audio i will be wanting to get the value of the path at x time, what is the best way to do that?

A 2D path is totally the wrong kind of mathematical object for an automation curve.. Normally you'd store a sequence of points instead, and although you'd draw it with a Path, that's not what you'd use to manipulate the data.

Makes sense, thanks for your help.