Old 01-02-2022, 09:46 PM   #881
GameAudioRvlzzr
Human being with feelings
 
GameAudioRvlzzr's Avatar
 
Join Date: Apr 2016
Location: Stuttgart, Germany
Posts: 217
Default

Hello dear lifesavers,
in Scythe, this Menubox makes Reaper crash:

Code:
{
	name = "Menubox",
	type = "Menubox",
	caption = "",
	x = 10,
	y = 10,
	options = { ">folder", "option 1", "option 2", "<last option" }
}
If i remove the first and the last option, it works (but then i have no folder).
Isn't using ">" and "<" how folders are supposed to work?
That's how i understand the documentation. Couldn't find any examples with folders.
Thank you for any help
Micha
GameAudioRvlzzr is offline   Reply With Quote
Old 01-03-2022, 09:10 AM   #882
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by GameAudioRvlzzr View Post
Hello dear lifesavers,
in Scythe, this Menubox makes Reaper crash:

Code:
{
	name = "Menubox",
	type = "Menubox",
	caption = "",
	x = 10,
	y = 10,
	options = { ">folder", "option 1", "option 2", "<last option" }
}
If i remove the first and the last option, it works (but then i have no folder).
Isn't using ">" and "<" how folders are supposed to work?
That's how i understand the documentation. Couldn't find any examples with folders.
Thank you for any help
Micha
Hi Micha,

I did a quick test here and it looks like the issue (or bug?) is that the first menubox element cannot be the start of a folder.

In comparison, this works here (adding one element before the folder):
Code:
options = { "first element", ">folder", "option 1", "option 2", "<last option" }
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 01-03-2022, 03:15 PM   #883
GameAudioRvlzzr
Human being with feelings
 
GameAudioRvlzzr's Avatar
 
Join Date: Apr 2016
Location: Stuttgart, Germany
Posts: 217
Default

Quote:
Originally Posted by solger View Post
Hi Micha,

I did a quick test here and it looks like the issue (or bug?) is that the first menubox element cannot be the start of a folder.

In comparison, this works here (adding one element before the folder):
Code:
options = { "first element", ">folder", "option 1", "option 2", "<last option" }
Ah! Thank you!!
GameAudioRvlzzr is offline   Reply With Quote
Old 01-07-2022, 08:32 AM   #884
loTrT
Human being with feelings
 
Join Date: Feb 2021
Posts: 13
Default

Hello all!

I am having a bug or i am misusing the GUI. I have a problem with "TEXTBOX" in Lokasenna GUI v2.

if i want to SET the displayed text l write this:

Code:
GUI.Val("textbox name", "text to be displayed")
if i want to GET the displayed text to be displayed l write this:

Code:
displayedText = GUI.Val("textbox name")
i put this functions insie oter fonctions or at the reascript procedural level.

It works, but... there is a problem with the text green selection with the mouse, i cant select all the displayed text, but only the first part of it, and same with the blinking caret it has an offset to the left equal to the green selection offset.

What am i doing wrong?

thanks


Last edited by loTrT; 01-07-2022 at 08:45 AM.
loTrT is offline   Reply With Quote
Old 01-08-2022, 05:59 AM   #885
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by loTrT View Post
Hello all!

I am having a bug or i am misusing the GUI. I have a problem with "TEXTBOX" in Lokasenna GUI v2.

if i want to SET the displayed text l write this:

Code:
GUI.Val("textbox name", "text to be displayed")
if i want to GET the displayed text to be displayed l write this:

Code:
displayedText = GUI.Val("textbox name")
i put this functions insie oter fonctions or at the reascript procedural level.

It works, but... there is a problem with the text green selection with the mouse, i cant select all the displayed text, but only the first part of it, and same with the blinking caret it has an offset to the left equal to the green selection offset.

What am i doing wrong?

thanks

Hello,

difficult to guess without knowing more details or the rest of your code.

Can you post a small code example where this problem occurs?
And what operating system (Windows, macOS or Linux) are you using in this case?
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 01-08-2022, 08:03 AM   #886
storyteller
Human being with feelings
 
Join Date: Aug 2016
Posts: 232
Default

Quote:
Originally Posted by loTrT View Post
Hello all!

I am having a bug or i am misusing the GUI. I have a problem with "TEXTBOX" in Lokasenna GUI v2.

if i want to SET the displayed text l write this:

Code:
GUI.Val("textbox name", "text to be displayed")
if i want to GET the displayed text to be displayed l write this:

Code:
displayedText = GUI.Val("textbox name")
i put this functions insie oter fonctions or at the reascript procedural level.

It works, but... there is a problem with the text green selection with the mouse, i cant select all the displayed text, but only the first part of it, and same with the blinking caret it has an offset to the left equal to the green selection offset.

What am i doing wrong?

thanks

I had a similar issue in Scythe when building OTR’s GUI Editor for Reaticulate. I will have to go back and see what exactly I changed to solve it, but I remember having to edit the Scythe 3 text box code itself that is published by Loksanna. It was a gnarly bug that took way too much time for me to resolve. If I recall, the change was super simple though, but not intuitive…
storyteller is offline   Reply With Quote
Old 01-08-2022, 08:37 AM   #887
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

I'm not sure if this is bad form or not, but perhaps since Lokasenna's GUI library isn't being maintained anymore, it's probably kosher.

The GUI framework I wrote for Reaticulate is now available as a separate library called rtk (REAPER Toolkit):

https://forum.cockos.com/showthread.php?t=255897

The widget set isn't as mature as Lokasenna v2/Scythe yet, but the foundation is strong, and I think the documentation is quite good, if I do say so myself.

I think it's a viable alternative for many kinds of scripts, if you can work within the current anemia of widgets (which I will be fleshing out this year). Certainly it's working well for Reaticulate.
tack is offline   Reply With Quote
Old 01-08-2022, 09:02 AM   #888
loTrT
Human being with feelings
 
Join Date: Feb 2021
Posts: 13
Default

Quote:
Originally Posted by solger View Post
Hello,

difficult to guess without knowing more details or the rest of your code.

Can you post a small code example where this problem occurs?
And what operating system (Windows, macOS or Linux) are you using in this case?
Hi solger and storyteller, thanks for replying!
I am on MacOS 10.15.7 bit the bug appears also on Windows machines.

Here is a ReaScript full code showing the bug (I removed all the rest of my code but the bug persist, so its unrelated to my code).

You can copy/paste it to a new empty ReaScript and run it to verify yourself.

Thank you very much, hoping we can figure out what's causing the selection/caret offset.
And maybe ask to update the GUI library code itself ? So that users downloading the Lokasenna GUI v2 dont have it?

Code:
--[[
Reascript made for the reaper forum with the intent to show and solve the selcetion & caret bugs
]]

-- Lokasenna's GUI Builder

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 - Textbox.lua")()



-- If any of the requested libraries weren't found, abort the script.
if missing_lib then return 0 end

GUI.name = "Multi Format Renders"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 520, 450
GUI.anchor, GUI.corner = "mouse", "C"



--My Script----------------------------------------------------

--[[
I REMOVED THE REASCRIPT CODE UNRELATED TO THIS BUG TEST
]]

--GUI OBJECTS-------------------------------------------------

--Textboxes

GUI.New("checkbox 1", "Textbox", {
    z = 11,
    x = 128,
    y = 16,
    w = 370,
    h = 20,
    caption = "checkbox 1",
    cap_pos = "left",
    font_a = 3,
    font_b = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})

GUI.New("checkbox 2", "Textbox", {
    z = 11,
    x = 128,
    y = 48,
    w = 294,
    h = 20,
    caption = "checkbox 2",
    cap_pos = "left",
    font_a = 3,
    font_b = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})

GUI.New("checkbox 3", "Textbox", {
    z = 11,
    x = 168,
    y = 170,
    w = 254,
    h = 20,
    caption = "checkbox 3",
    cap_pos = "left",
    font_a = 3,
    font_b = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})

GUI.New("checkbox 4", "Textbox", {
    z = 11,
    x = 128,
    y = 80,
    w = 40,
    h = 20,
    caption = "checkbox 4",
    cap_pos = "left",
    font_a = 3,
    font_b = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})

GUI.New("checkbox 5", "Textbox", {
    z = 11,
    x = 260,
    y = 80,
    w = 236,
    h = 20,
    caption = "checkbox 5",
    cap_pos = "left",
    font_a = 3,
    font_b = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})

GUI.New("checkbox 6", "Textbox", {
    z = 11,
    x = 128,
    y = 110,
    w = 295,
    h = 20,
    caption = "checkbox 6",
    cap_pos = "left",
    font_a = 3,
    font_b = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})

GUI.New("checkbox 7", "Textbox", {
    z = 11,
    x = 128,
    y = 140,
    w = 295,
    h = 20,
    caption = "checkbox 8",
    cap_pos = "left",
    font_a = 3,
    font_b = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})



GUI.Init()
GUI.Main()
or if you prefer you can download it, the attached file here:
Attached Files
File Type: lua lokasennaV2-Textbox-selection-bug.lua (2.9 KB, 113 views)

Last edited by loTrT; 01-08-2022 at 09:13 AM.
loTrT is offline   Reply With Quote
Old 01-08-2022, 09:27 AM   #889
storyteller
Human being with feelings
 
Join Date: Aug 2016
Posts: 232
Default

Hey - so here was my fix... but remember, this was in Scythe thought it was also developed by Loksanna. The fix was based on a GitHub comment, but I'm betting it is the same problem. It looks identical to the Scythe issue I experienced.

The code is found in library/gui/elements/textbox.lua

The commented out code is the original version. The line that has a comment after it "this seems to work better" is the fix.
Code:
--this is the modified fix via a recommended fix in the Scythe github...
function Textbox:val(newval)
	if newval then 
		--self:setEditorState(tostring(newval), nil, string.len(newval) + 2 - self.windowW) 
		self:setEditorState(tostring(newval)) --this seems to work better 
		self:redraw() 
	else 
		return self.retval 
	end 
end
storyteller is offline   Reply With Quote
Old 01-08-2022, 09:34 AM   #890
storyteller
Human being with feelings
 
Join Date: Aug 2016
Posts: 232
Default

Looking at the Loksanna GUI v2 code (and applying the same concept from my scythe 3 fix), I'd wager that the issue would be in the function below from:

library/classes/textbox.lua:

Code:
function GUI.Textbox:seteditorstate(retval, caret, wnd_pos, sel_s, sel_e)

    self.retval = retval or ""
    self.caret = math.min(caret and caret or self.caret, string.len(self.retval))
    self.wnd_pos = wnd_pos or 0
    self.sel_s, self.sel_e = sel_s or nil, sel_e or nil

end
But, I don't have time to go through and troubleshoot the code since it is unsupported and I have a lot on my plate at the moment. Just trying to point you in the right direction. (hopefully the right direction)
storyteller is offline   Reply With Quote
Old 01-08-2022, 09:46 AM   #891
loTrT
Human being with feelings
 
Join Date: Feb 2021
Posts: 13
Default

Quote:
Originally Posted by storyteller View Post
Hey - so here was my fix... but remember, this was in Scythe thought it was also developed by Loksanna. The fix was based on a GitHub comment, but I'm betting it is the same problem. It looks identical to the Scythe issue I experienced.

The code is found in library/gui/elements/textbox.lua

The commented out code is the original version. The line that has a comment after it "this seems to work better" is the fix.
Code:
--this is the modified fix via a recommended fix in the Scythe github...
function Textbox:val(newval)
	if newval then 
		--self:setEditorState(tostring(newval), nil, string.len(newval) + 2 - self.windowW) 
		self:setEditorState(tostring(newval)) --this seems to work better 
		self:redraw() 
	else 
		return self.retval 
	end 
end
Hi thanks for replying so quick but well.. this is funny because...
in "Lokasenna GUI v2" inside the "Class - Textbox.lua" the default code is already like your fix at line 136:



my quest isnt over for this bug then ehe, lets see if solger has some ideas maybe
loTrT is offline   Reply With Quote
Old 01-08-2022, 09:51 AM   #892
loTrT
Human being with feelings
 
Join Date: Feb 2021
Posts: 13
Default

Quote:
Originally Posted by storyteller View Post
Looking at the Loksanna GUI v2 code (and applying the same concept from my scythe 3 fix), I'd wager that the issue would be in the function below from:

library/classes/textbox.lua:

Code:
function GUI.Textbox:seteditorstate(retval, caret, wnd_pos, sel_s, sel_e)

    self.retval = retval or ""
    self.caret = math.min(caret and caret or self.caret, string.len(self.retval))
    self.wnd_pos = wnd_pos or 0
    self.sel_s, self.sel_e = sel_s or nil, sel_e or nil

end
But, I don't have time to go through and troubleshoot the code since it is unsupported and I have a lot on my plate at the moment. Just trying to point you in the right direction. (hopefully the right direction)
ok thanks again i ll check here for now
loTrT is offline   Reply With Quote
Old 01-08-2022, 12:35 PM   #893
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Thanks for the code example.

I compared your code with a generated code example from the v2 GUI Builder and I think I found the issue.
Changing the font_b values of the textboxes from 3 to "monospace" seems to fix the issue:
Code:
font_a = 3,
font_b = "monospace",
EDIT: Removing the font_b line should also have the same effect (so the default font_b value is used for the textboxes).
__________________
ReaLauncher

Last edited by solger; 01-08-2022 at 12:52 PM.
solger is offline   Reply With Quote
Old 01-08-2022, 03:02 PM   #894
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Additional note to my previous post:

it looks like a monospace font is expected for the textbox to work correctly (and using a sans-serif font instead 'breaks things').


For reference, here are the lines in the Core.lua file of the default fonts used in the v2 GUI library:
Code:
GUI.OS_fonts = {
    Windows = {
        sans = "Calibri",
        mono = "Lucida Console"
    },
    OSX = {
        sans = "Helvetica Neue",
        mono = "Andale Mono"
    },
    Linux = {
        sans = "Arial",
        mono = "DejaVuSansMono"
    }
}

GUI.get_OS_fonts = function()
    local os = reaper.GetOS()
    if os:match("Win") then
        return GUI.OS_fonts.Windows
    elseif os:match("OSX") then
        return GUI.OS_fonts.OSX
    else
        return GUI.OS_fonts.Linux
    end
end
	
local fonts = GUI.get_OS_fonts()
GUI.fonts = {

                -- Font, size, bold/italics/underline
                -- 				^ One string: "b", "iu", etc.
                {fonts.sans, 32},	-- 1. Title
                {fonts.sans, 20},	-- 2. Header
                {fonts.sans, 16},	-- 3. Label
                {fonts.sans, 16},	-- 4. Value
    monospace = {fonts.mono, 14},
    version = 	{fonts.sans, 12, "i"},
}


And here are two examples if you want to adjust the textbox font size (from 14 to 10) in your code from post #888:


1) Defining a custom font and then using this one as font_b:
Code:

local fonts = GUI.get_OS_fonts()
local myFont = { fonts.mono, 10 } -- font size: 10 (default: 14)


GUI.New("checkbox 1", "Textbox", {
    z = 11,
    x = 128,
    y = 16,
    w = 370,
    h = 20,
    caption = "checkbox 1",
    cap_pos = "left",
    font_a = 3,
    font_b = myFont,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})

2) Overriding the default "monospace" font with the new size. An removing the font_b parameter in the GUI.New Textbox code (since the "monospace" font is used by default).
Code:
local fonts = GUI.get_OS_fonts()
GUI.fonts["monospace"] = { fonts.mono, 10 }

GUI.New("checkbox 1", "Textbox", {
    z = 11,
    x = 128,
    y = 16,
    w = 370,
    h = 20,
    caption = "checkbox 1",
    cap_pos = "left",
    font_a = 3,
    color = "white",
    bg = "wnd_bg",
    shadow = true,
    pad = 4,
    undo_limit = 20
})
__________________
ReaLauncher

Last edited by solger; 01-08-2022 at 03:25 PM.
solger is offline   Reply With Quote
Old 01-10-2022, 10:27 AM   #895
loTrT
Human being with feelings
 
Join Date: Feb 2021
Posts: 13
Default

Hi solger thank you very much for the tips and the solution for avoiding the bug!

Indeed after your first comment i figured out that Lokasenna must have specified the selection exclusively for a "monospaced font", where each characters occupy the same amount of horizontal space.
I dont even think that i can change the monospaced font, but the size would be nice especially on Mac. I ll try your code examples for that.
loTrT is offline   Reply With Quote
Old 01-14-2022, 06:33 PM   #896
GameAudioRvlzzr
Human being with feelings
 
GameAudioRvlzzr's Avatar
 
Join Date: Apr 2016
Location: Stuttgart, Germany
Posts: 217
Default Textbox contents cut off depending on font size

Edit: I couldn't solve the problem below, so i decided to use Frames instead of Textboxes. Not ideal, since now other functionality is missing, but in my case, that's ok. Still, if anybody knows a solution, i'd be happy to read it.


Hi!
Me again with another problem in Scythe:

At font size 10, these 4 textboxes show the correct string:



But if i set the font size to something larger, like 14, the beginning gets cut off!
(Only the first 2 boxes which have longer strings)
"12-String Guitar" becomes "ring Guitar"!



Why could this be? Shurely, it can't be a lack of horizontal space...?
The font is Lucida Console, a monospaced font.

Thank you, Micha
Attached Images
File Type: png Textbox cut off large.png (4.9 KB, 844 views)
File Type: png Textbox cut off small.png (4.8 KB, 816 views)

Last edited by GameAudioRvlzzr; 01-16-2022 at 07:52 PM. Reason: Update
GameAudioRvlzzr is offline   Reply With Quote
Old 01-17-2022, 10:42 AM   #897
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by GameAudioRvlzzr View Post
Edit: I couldn't solve the problem below, so i decided to use Frames instead of Textboxes. Not ideal, since now other functionality is missing, but in my case, that's ok. Still, if anybody knows a solution, i'd be happy to read it.


Hi!
Me again with another problem in Scythe:

At font size 10, these 4 textboxes show the correct string:



But if i set the font size to something larger, like 14, the beginning gets cut off!
(Only the first 2 boxes which have longer strings)
"12-String Guitar" becomes "ring Guitar"!



Why could this be? Shurely, it can't be a lack of horizontal space...?
The font is Lucida Console, a monospaced font.

Thank you, Micha
I cannot reproduce the problem here. So not sure what's causing this.
Can you post a short example code with the problem so I can check if it behaves the same here?

In general, you might have to call textBoxName:recalculateWindow() afterwards to update some internal values: https://jalovatt.github.io/scythe/#/...ements/Textbox
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 05-07-2022, 12:36 PM   #898
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default Capturing global keystrokes?

Is there any way using the gfx interface to capture keystrokes that have been designated as "global" in the reaper-kb.ini file? In other words, when you do gfx.mouse_cap and gfx.getchar() to get a keystroke from the keyboard queue, it doesn't show up if that keystroke is designated as a "global" keystroke in the reaper-kb.ini file. Is there anyway to intercept it before REAPER gobbles it up?

Last edited by cohler; 05-07-2022 at 12:42 PM.
cohler is offline   Reply With Quote
Old 05-17-2022, 12:02 PM   #899
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default GUI invisible to screen readers

Is there a way to make the windows created by Lokasenna GUI visible to screen reader software like Voiceover on the Mac or NVDA on Windows?
cohler is offline   Reply With Quote
Old 11-02-2022, 02:31 AM   #900
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Code:
local layer = GUI.createLayer({name = "Layer1"})
layer:addElements( GUI.createElements(
{
  name = "1",
  type = "Button",
  x = 8,
  y = 10,
  w = 60,
  h = 30,
  textColor = white,
  fillColor = rd,
  caption = "test",
  func = myfunction,
}
Hi all,
Is it possible to have a button change fillColor when it has been clicked on and then revert to the original fillColor when another button is clicked ?
I would like to keep track of the last clicked button by highlighting it.
Many thanks,
J.
J Reverb is offline   Reply With Quote
Old 11-02-2022, 04:23 AM   #901
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Yes just add the same button code and new color/text in the function that is being called using the same layer, position and size but add an ondelete and init so it will delete the original then initialize it. Then that button will call another function and set the button back to original color/text.

Code:
GUI.elms.verse_btn:ondelete() 
GUI.New("verse_btn",     "Button",          1, 150+x1, 162+y1, 64, 24, "Verse", verse_btn_click)
GUI.elms.verse_btn.col_txt = "white"
GUI.elms.verse_btn.col_fill = "verse"    
GUI.elms.verse_btn:init()
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 11-02-2022 at 04:30 AM.
MusoBob is offline   Reply With Quote
Old 11-02-2022, 12:34 PM   #902
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by J Reverb View Post
Hi all,
Is it possible to have a button change fillColor when it has been clicked on and then revert to the original fillColor when another button is clicked ?
I would like to keep track of the last clicked button by highlighting it.
Many thanks,
J.
Hi,

the examples in this thread might also be interesting: https://forum.cockos.com/showthread.php?t=234642
__________________
ReaLauncher
solger is offline   Reply With Quote
Old 11-03-2022, 02:48 PM   #903
J Reverb
Human being with feelings
 
Join Date: Jul 2009
Posts: 1,071
Default

Thanks guys,
I am trying to use v3 and all the code is different.
Not sure how to access the fillColor
I have all the basics working but changing stuff on a mouse click is illuding me
Thanks for your help ! thumbs up !
J Reverb is offline   Reply With Quote
Old 11-04-2022, 07:52 AM   #904
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by J Reverb View Post
Thanks guys,
I am trying to use v3 and all the code is different.
Not sure how to access the fillColor
I have all the basics working but changing stuff on a mouse click is illuding me
Thanks for your help ! thumbs up !
Here's a simple v3 code example that should give you a good starting point.
Code:
local libPath = reaper.GetExtState("Scythe v3", "libPath")
if not libPath or libPath == "" then
    reaper.MB("Couldn't load the Scythe library. Please install 'Scythe library v3' from ReaPack, then run 'Script: Scythe_Set v3 library path.lua' in your Action List.", "Whoops!", 0)
    return
end

loadfile(libPath .. "scythe.lua")()
local GUI = require("gui.core")

local window = GUI.createWindow({
  name = "Scythe Test",
  w = 400,
  h = 250
})

local buttonLayer = GUI.createLayer({
  name = "ButtonLayer"
})

local defaultButtonColor = "elementBody"
local selectedButtonColor = "green"

local function UpdateButtonColor(lastClickedButton)
  -- reset/initialize the fillColor
  button1.fillColor = defaultButtonColor
  button1:init()
  
  button2.fillColor = defaultButtonColor
  button2:init()
  
  button3.fillColor = defaultButtonColor
  button3:init()
  
  -- set the fillColor of the last clicked button
  lastClickedButton.fillColor = selectedButtonColor
  lastClickedButton:init()
end

button1 = GUI.createElement({
  name = "Button1",
  type = "Button",
  x = 20,
  y = 16,
  caption = "1",
  func = function() UpdateButtonColor(button1) end
})

button2 = GUI.createElement({
  name = "Button2",
  type = "Button",
  x = 120,
  y = 16,
  caption = "2",
  func = function() UpdateButtonColor(button2) end
})

button3 = GUI.createElement({
  name = "Button3",
  type = "Button",
  x = 220,
  y = 16,
  caption = "3",
  func = function() UpdateButtonColor(button3) end
})

buttonLayer:addElements(button1)
buttonLayer:addElements(button2)
buttonLayer:addElements(button3)
window:addLayers(buttonLayer)
window:open()
GUI.Main()
And another example where all button elements are added to a table 'buttonElements' which is then iterated through.
Differences to the first code are highlighted in bold.
Code:
local libPath = reaper.GetExtState("Scythe v3", "libPath")
if not libPath or libPath == "" then
    reaper.MB("Couldn't load the Scythe library. Please install 'Scythe library v3' from ReaPack, then run 'Script: Scythe_Set v3 library path.lua' in your Action List.", "Whoops!", 0)
    return
end

loadfile(libPath .. "scythe.lua")()
local GUI = require("gui.core")

local window = GUI.createWindow({
  name = "Scythe Test",
  w = 400,
  h = 250
})

local buttonLayer = GUI.createLayer({
  name = "ButtonLayer"
})

local defaultButtonColor = "elementBody"
local selectedButtonColor = "green"

local function UpdateButtonColor(lastClickedButton)
  -- reset/initialize the fillColor
  for e = 1, #buttonElements do
    buttonElements[e].fillColor = defaultButtonColor
    buttonElements[e]:init()
  end  
  
  -- set the fillColor of the last clicked button
  lastClickedButton.fillColor = selectedButtonColor
  lastClickedButton:init()
end

button1 = GUI.createElement({
  name = "Button1",
  type = "Button",
  x = 20,
  y = 16,
  caption = "1",
  func = function() UpdateButtonColor(button1) end
})

button2 = GUI.createElement({
  name = "Button2",
  type = "Button",
  x = 120,
  y = 16,
  caption = "2",
  func = function() UpdateButtonColor(button2) end
})

button3 = GUI.createElement({
  name = "Button3",
  type = "Button",
  x = 220,
  y = 16,
  caption = "3",
  func = function() UpdateButtonColor(button3) end
})

buttonElements = {
  button1,
  button2,
  button3
}

buttonLayer:addElements(button1)
buttonLayer:addElements(button2)
buttonLayer:addElements(button3)
window:addLayers(buttonLayer)
window:open()
GUI.Main()
__________________
ReaLauncher

Last edited by solger; 11-04-2022 at 08:43 AM. Reason: minor code update
solger is offline   Reply With Quote
Old 05-21-2023, 01:07 PM   #905
jkooks
Human being with feelings
 
Join Date: May 2020
Posts: 190
Default

For anyone still using Lokasenna_GUI I just published a new Tree class to use in GUIs. Feel free to read about it in the forum post that I made, or just go straight to the GitHub to download the class file and read the README file.

https://forum.cockos.com/showthread....20#post2678820
https://github.com/jkooks/Lokasenna_GUI-Tree/tree/main
jkooks 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 01:25 PM.


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