FrSkyRC / ETHOS-Feedback-Community

Feedback & suggestions are welcomed here for ETHOS by FrSky
189 stars 85 forks source link

addChoiceField always uses 3rd item as default #4544

Open noamkrief opened 3 weeks ago

noamkrief commented 3 weeks ago

addChoiceField always uses 3rd option as default. If there are only 2 options, you get "???" in the choice field.

It would be nice to be able to select a default item. THANKS!

bsongis-frsky commented 3 weeks ago

Perhaps your getValue handler doesn't return something right? Or you wouldn't have "???" in the choice field.

It will be easier to help if you paste your script here!

noamkrief commented 3 weeks ago

@bsongis-frsky

local function create() return { battery_alert = false, } end

local function wakeup(widget)

end

local function paint(widget)

end

local function configure(widget) line = form.addLine("Battery Type") form.addChoiceField(line, nil, {{"Lipo", 1}, {"HV Lipo", 2}, {"Lion", 3}, {"LiFe", 4}}, function() return widget.BattType end, function(value) print(value) widget.BattType = value end) --widget.BattType_field:default(1)

end

local function read(widget) widget.BattType = storage.read ("BattType")

end

local function write(widget) storage.write("BattType" , widget.BattType)

end

local function init() system.registerWidget({key="noam", name="noam", create=create, paint=paint, configure=configure, read=read, write=write, wakeup=wakeup}) Init = false end

return {init=init}