[JW Lua] Combining NumberedList and Number in the dialog - solved
Jan Angermüller
jan at angermueller.com
Tue Feb 10 13:24:02 CET 2015
On 2014-09-13 21:12, Jari Williamsson wrote:
> Mixing NumberedList and Number types in a dialog is not yet supported
> for SetLists(). This has to do with a future feature I had in mind.
Here is a simple solution for the above mentioned problem of combining
lists with other types in a dialog on-the-fly which has not been solved
yet in finenv.UserValueInput():SetLists().
Simply use SetLists() in a Load() statement. See example code below.
The only drawback: the dialog variable needs to be global now. Otherwise
Load() won't work.
Best regards,
Jan
local dialogTypes={}
local dialogLists={}
local dialogDescriptions={}
local dialogInitValues={}
dialog = finenv.UserValueInput()
local displaylist = '{"aa","bb"}'
local numelements=3
local s="dialog:SetLists("
local i=1
while i <= numelements do
if i>1 then
s=s..","
end
table.insert(dialogTypes,"NumberedList")
table.insert(dialogTypes,"Number")
table.insert(dialogTypes,"String")
s=s..displaylist..","
s=s.."nil,"
s=s.."nil"
table.insert(dialogDescriptions,i..".) Element 1")
table.insert(dialogDescriptions,i..".) Element 2")
table.insert(dialogDescriptions,i..".) Element 3")
table.insert(dialogInitValues,1)
table.insert(dialogInitValues,1)
table.insert(dialogInitValues,"test")
i=i+1
end
s=s..")"
dialog.Title = "Dialog title"
dialog:SetTypes(dialogTypes)
load(s)()
dialog:SetDescriptions(dialogDescriptions)
dialog:SetInitValues(dialogInitValues)
local returnvalues = dialog:Execute()
More information about the JWLua
mailing list