warmenu icon indicating copy to clipboard operation
warmenu copied to clipboard

Combobox return nil

Open BardaAvishunden opened this issue 1 year ago • 4 comments

Fixed an nil value on the combobox default value

BardaAvishunden avatar Jul 01 '24 13:07 BardaAvishunden

What's the purpose of this change? API is designed that you store starting current index explicitly and pass it to widget function.

warxander avatar Jul 01 '24 19:07 warxander

Only purpose is ease of use. Didnt want to put all my default values in when opening the menu, also not "resetting" settings when opening cus values getting called.

BardaAvishunden avatar Jul 01 '24 19:07 BardaAvishunden

Please provide some more details. Because as I understand, the UI state is managed in the following way:

local state = { }

-- Reset state to default
-- Call it on script init and when menu was closed or just opened
function resetState()
  state.index = 1
end

-- Menu loop
local _, state.index = WarMenu.ComboBox('Text', items, state.index)

warxander avatar Jul 02 '24 11:07 warxander

If defualt states is not set when opening the menu the combobox will return nil. This is just ease of use so you dont have to set default values and potentially not being able to set settings cus the get reset when opening the menu

BardaAvishunden avatar Jul 02 '24 12:07 BardaAvishunden