Skip to content

Re‐Write uiCombo Contents from a Table

Damien S edited this page Jun 30, 2024 · 1 revision

Re-Write uiCombo Contents from a Table by spiffo-smith

Sometimes it becomes necessary to re-write the uiCombo Contents and this throws up a series of problems, below is a script I just wrote that takes care of things:

function replace_uiCombo_content_from_table(combo, table)

local string = "" local size = 0 local orig_value = panel:getModulatorByName(combo):getModulatorValue()

panel:getModulatorByName(combo):setValue(-1, false, true)

if table ~= nil then

`for k, v in pairs(table) do`
	`size = size + 1`
`end`

`for i = 1, size-1 do`
	`add = table[i]`
	`add = string.gsub (add, "[^%w]", "")`
	`string = string..add`
	`if i ~= size-1 then string = string.."\n" else end`
`end`

`panel:getModulatorByName(combo):getComponent():setProperty("uiComboContent" , string, false)`
`panel:getModulatorByName(combo):setValue(orig_value, false, true)`

else end end