Old 02-19-2021, 01:13 PM   #1
noah1234j
Human being with feelings
 
Join Date: Jan 2021
Posts: 22
Default Lokasenna GUI.Val issues

Hi Everyone, New to programming and having some issues with Lokasenna v2.

When I click point 5 in a listbox
GUI.Val("My Element") -- Returns 5, as expected

But when I set the selection from the program
GUI.Val("My Element", 7) -- the selection jumps to point 7 as expected

Now Here's the problem, after setting the value from the program. When I inquire about it again.

GUI.Val("My Element") -- 7 is selected, but returns 1

No Idea why this is happening, probably something really simple. Please help.
noah1234j is offline   Reply With Quote
Old 02-19-2021, 01:40 PM   #2
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Welcome to the Reaper Forums!

Can you please post the rest of your code (placed inside [CODE] tags, so it's easier to read and doesn't change the formatting). Or attach the script file to a post.
Otherwise it's difficult to guess what the source of the problem might be.


And as a general side note (in case you haven't found these already)

EDIT: Not sure if this info from the documentation (https://github.com/jalovatt/Lokasenn...i/2.00-Listbox) might help:

Depending on if the multi-select parameter is enabled for the Listbox, GUI.Val returns:
Quote:
GUI.Val("my_list")
Returns either a single item number (multi = false), or a table (multi = true) with the indices of each selected item.
__________________
ReaLauncher

Last edited by solger; 02-19-2021 at 03:39 PM.
solger is offline   Reply With Quote
Old 02-20-2021, 09:29 PM   #3
noah1234j
Human being with feelings
 
Join Date: Jan 2021
Posts: 22
Default

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.
noah1234j is offline   Reply With Quote
Old 02-20-2021, 09:48 PM   #4
noah1234j
Human being with feelings
 
Join Date: Jan 2021
Posts: 22
Default

I went ahead and posted the question on the Lokasenna GUI Thread you shared. Thank you for your help and if it would be easier to reply there please do.
noah1234j is offline   Reply With Quote
Old 02-23-2021, 12:21 PM   #5
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by noah1234j View Post
I went ahead and posted the question on the Lokasenna GUI Thread you shared. Thank you for your help and if it would be easier to reply there please do.
Thanks for the code. And yeah, let's continue in that thread

For others that are interested (starts at post #827): https://forum.cockos.com/showthread....94#post2408894
__________________
ReaLauncher
solger is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.