# A generic function for hiding controls based on a parameter value

**URL:** <https://forum.electra.one/t/a-generic-function-for-hiding-controls-based-on-a-parameter-value/2744>\
**Category:** Developers\
**Tags:** lua, preset\
**Created:** [March 17, 2024, 12:41pm UTC](https://forum.electra.one/t/a-generic-function-for-hiding-controls-based-on-a-parameter-value/2744 "2024-03-17T12:41:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NewIgnis](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.electra.one/newignis/32/767_2.png) [@NewIgnis](https://forum.electra.one/u/NewIgnis)\
**Post date:** [March 17, 2024, 12:41pm UTC](https://forum.electra.one/t/a-generic-function-for-hiding-controls-based-on-a-parameter-value/2744/1 "2024-03-17T12:41:54Z")

</div>

In the last V0.3 version of [Electra One App](https://app.electra.one/preset/pk0s8g53AxbvqI4TWpVf), I’ve made a generic ‘hideCtrl’ function for hiding controls.

In the elements of table ctrl2Hide you tell:

- which parameter will influence
- what control,
- based on which value,
- and whether it needs to be visible then or not.

The function only works when only one value of the parameter is making the difference between a control being visible or not.

Add the function only to the controlling parameters.  
Parameter 12047 is a switch you can add: the hidings will then only work if the switch is On. This way you can temporarily cancel the hiding effect.

```auto
function hideCtrl(valueObject, value) --- hides non used parameters
  -- table element: {paramNumber,ctrl2change,value2check, boolVis at value2check}
  local ctrl2Hide={{22,75,0,true},{22,76,0,true},{25,82,0,false},{25,78,0,false},{25,79,0,false},{25,80,0,false}, --legato,portamento
    {4100,136,1,true},{4100,137,1,true},{4100,138,1,true},{4100,139,1,true}, -- TMT velo control switch
    {11212,290,1,true},{11209,270,0,true},{11209,271,0,true},{11209,272,0,false},{11209,273,0,false}, -- HOLD switch, tone FX send
    {11245,183,1,true},{11245,184,1,true},{1027,403,1,false}, -- FXM switch , Chorus Out
    {11301,346,10,false},{11301,348,10,false},{11315,363,10,false},{11315,369,10,false} -- LFO1 LFO2
  }
  local paramNumber = valueObject:getMessage ():getParameterNumber ()
  local boolVis = true
  for _, pair in ipairs(ctrl2Hide) do
    if pair[1] == paramNumber then
      control = controls.get (pair[2])
      if pair[3] == value then boolVis = pair[4] else boolVis = not(pair[4]) end
      if parameterMap.get (deviceId, PT_VIRTUAL, 12047) == 0 then boolVis = true end --- override the hide modes
      control:setVisible (boolVis)    
    end
  end
end

```
