Thanks for your quick reply Solger, and thank you for the resources. I wasn't aware there was a dedicated script section. I'm not sure if I can switch this post to the script section now that it's posted? or Should I repost my question there?
Here is my code, I tried to cut out everything unnecessary.
Code:
local lib_path = reaper.GetExtState("Lokasenna_GUI", "lib_path_v2")
if not lib_path or lib_path == "" then
reaper.MB("Couldn't load the Lokasenna_GUI library. Please install 'Lokasenna's GUI library v2 for Lua', available on ReaPack, then run the 'Set Lokasenna_GUI v2 library path.lua' script in your Action List.", "Whoops!", 0)
return
end
loadfile(lib_path .. "Core.lua")()
GUI.req("Classes/Class - Listbox.lua")()
GUI.req("Classes/Class - Button.lua")()
function example_function()
GUI.Val("Listbox", 1) --Sets the index to 1
reaper.ShowConsoleMsg("Current index: " .. GUI.Val("Listbox")) --Lists 1 as the current index
GUI.Val("Listbox", 4) --Sets the index to 4
reaper.ShowConsoleMsg("Current index: " .. GUI.Val("Listbox")) --why does it list 1???? I would expect to get 4 in return
GUI.Val("Listbox", 3) --Sets the index to 3
reaper.ShowConsoleMsg("Current index: " .. GUI.Val("Listbox")) --still lists 1?
end
GUI.New("Listbox", "Listbox", {
z = 11,
x = 80,
y = 32,
w = 192,
h = 96,
list = {"item 1", "item 2", "item 4", "item 5", "item 6"},
multi = false, -- For my purposes, I nee
caption = "Scenes"
})
GUI.New("Button", "Button", {
z = 12,
x = 80,
y = 160,
w = 70,
h = 20,
caption = "Push Me",
func = example_function --Here is where I trigger the function on the button click
})
GUI.Init()
GUI.Main()
I would add that this issue does not affect me after using the mouse to select the menu item. If I select the menu item with the mouse GUI.Val("Listbox") returns the correct value.