Home › Forums › General › Programming › “Global” On Mouse Down › Reply To: “Global” On Mouse Down
Interesting way of working for the randomizer!
Exactly as dnaldoog explained; I’m doing that all the time by sending the same type of modulator (button, rotary, rotary negative/postivie, pulldown, triple switches…) to a unique method then based on the name you adjust what you want.
If you assign all your mods to variables as well then you can write a complete generic code.
This is working for “value on change” or “component on click”, you just need to secure the distinction for name and value in your code.
You can also call your on click method from the on change one to avoid running the same code (but this is depending on what you doing in your code of course).
“value on change” method:
--
-- Called when a modulator value changes
-- @mod http://ctrlr.org/api/class_ctrlr_modulator.html
-- @value new numeric value of the modulator
--
PositiveValue_OnChange = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
-- No action while loading a program or if the panel is in bootstrap or program states
if bLoadingProgram or not isPanelReady() then
return
end
PositiveValue_OnClick(mod:getComponent())
sName= L(mod:getName())
end
“Component on click” method:
--
-- Called when a mouse is down on this component
-- Used to display parameter name and description for components with 0..n values
--
PositiveValue_OnClick = function(--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)
-- No action while the panel is in bootstrap or program states
if not isPanelReady() or not bLCD then
return
end
local sName = L(comp:getOwner():getName())
-- Get parameter name and description to be displayed
if sName == "VCO1Shape" then
sParameter = "Oscillator 1 Shape (0..1023)"
elseif sName == "VCO2Shape" then
sParameter = "Oscillator 2 Shape (0..1023)"