Home › Forums › General › Programming › getName with 'on-click' method? › Reply To: getName with 'on-click' method?
Please look at my Pro2 panel…
xxx_OnChange and xxx_OnClick methods are different.
When you create an xxx_OnChange method, you select luaModulatorValueChange
and the declaration is:
xxx_OnChange = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
When you create an xxx_OnClick method, you select componentLuaMouseDown
and the declaration is:
xxx_OnClick = function(--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)
So, in the OnChange, you have access to a modulator while in the OnClick you have access to the component.
In the OnClick method, to get the name of the parent modulator of a component you need to use
sName= L(comp:getOwner():getName())
From there it is easy to re-use the same OnClick for several modulators…
OSC1Freq, OSC2Freq, OSC3Freq…
Just get the name then isolate the 4 first characters (or only the 4th one) with string.sub and build a classical if..then…elseif…elseif…end check