Example of a color change needed

Hi, for some reason, I can’t get a color of a control changed via a value coming from a variable. Can someone provide me with a simple example so I understand how it it so be done?

thanks upfront

1 Like
-- Change colour of the control according to its value

-- The color of the control changes to orange when above
-- a threshold defined below.

-- declare a global threshold variable
threshold = 96

function applyColor (valueObject, value)
  local control = valueObject:getControl ()
  if (value <= threshold) then
    control:setColor (WHITE)
    control:setColor (ORANGE)

an example of a function callback. Is is just a simple version to understand the concept. The code is not efficient as it sets the colour on every value change.

You can see it in action at Change control colour preset.

1 Like

Hi @martin,
I got this code at work but I think I found a bug. I’ll report it in the ‘bug’ category