Old 06-04-2016, 02:02 PM   #1
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default Lokasenna's GUI library for Lua

GUIs. We all need them, and they're a bit of a pain to make in ReaScript. Why not let someone else do the hard work so you can get back to actually making your script do something cool?

Those of you who were brave enough to read through my GUI tutorial saw an early version of this, but now I feel like I've tidied things up enough for a proper release:



Examples using this library:
https://www.dropbox.com/s/0g68u8l7q5...setup.gif?dl=0
https://www.dropbox.com/s/n3xhciyd9x...elper.png?dl=0


Reasons why you should use this sexy beast include:

- Very little coding required on your part. The image above only needs about 50 lines of user code compared to the hundreds (or thousands, in this case) you'd have to write if you did it yourself.

- Global font and color settings, so you can change the overall look to suit your fancy.

- Visibility layer management, so you can have multiple sets of controls come and go as needed.

- Graphics use blitting whenever possible, keeping the CPU usage low without any worry on your part.

- Run your own functions as part of the GUI's updating loop. You could relabel the options around aknob if you wanted, or have a slider and knob match the selected track's volume/pan... etc.

- Can be told to exit from your own code, and to run a function when it does. For instance, "save all the current settings, run this action, and quit".

- Modular design, allowing you to use as much, or as little, of my own code as you want. You can also write your own classes if you'd prefer.

- Designed to be compatible with my Script Compiler, so you don't have to distribute and maintain a dozen extra files with your script.

Download:

Lokasenna_GUI on the ReaTeam Github repository - The library, element classes, a few example scripts, and a couple of READ MEs to help you fall asleep.

Enjoy!


Changelog:
xxx - July 31/17: A few bug fixes.

1.0 - June 9/17: First proper release. Classes are modular, tons of new features, code is much more efficient.

beta 2 - June 13/16: Rewrote the library to be copy/paste-able rather than distributing the file separately.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack

Last edited by Lokasenna; 07-31-2017 at 04:04 PM.
Lokasenna is offline   Reply With Quote
Old 06-04-2016, 06:13 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 4,041
Default

Thanks for your hard work on this, I'm sure it could be useful to a lot of scripters !!

Cheers !
X-Raym is offline   Reply With Quote
Old 06-04-2016, 10:19 PM   #3
michaeltonight
Human being with feelings
 
Join Date: Jun 2010
Location: Texas
Posts: 228
Default

This is amazing, Lokasenna.
michaeltonight is offline   Reply With Quote
Old 06-08-2016, 08:30 AM   #4
Ozman
Human being with feelings
 
Join Date: Feb 2015
Posts: 301
Default

This looks awesome!
Ozman is offline   Reply With Quote
Old 06-08-2016, 12:56 PM   #5
sfzgeek
Human being with feelings
 
sfzgeek's Avatar
 
Join Date: Feb 2009
Location: Dunedin, New Zealand
Posts: 204
Default

Bravo! Amazing work and excellent reference scripts!
__________________
My rawk band: The Hidden Venture.
sfzgeek is offline   Reply With Quote
Old 06-10-2016, 04:40 AM   #6
Brado231
Human being with feelings
 
Join Date: Sep 2012
Location: Oz
Posts: 194
Default

Great stuff! Thanks!!
Brado231 is offline   Reply With Quote
Old 06-11-2016, 05:16 AM   #7
raiirock
Human being with feelings
 
raiirock's Avatar
 
Join Date: Mar 2013
Posts: 85
Default

Looks great !
raiirock is online now   Reply With Quote
Old 06-13-2016, 08:49 PM   #8
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

Update to beta 2.

No feature changes, but I rewrote a couple of things so the library can now be copy/pasted into your script rather than distributing the file separately. See the comments at the beginning of the file for instructions.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 06-14-2016, 06:21 PM   #9
Spacemen Tree
Human being with feelings
 
Spacemen Tree's Avatar
 
Join Date: Mar 2013
Posts: 484
Default

Just the licecap in the OP screams AWESOME!!!

Great stuff. Kudos!
__________________
"After silence, that which comes nearest to expressing the inexpressible is music", Aldous Huxley
Spacemen Tree is offline   Reply With Quote
Old 06-15-2016, 11:14 AM   #10
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,286
Default

I haven't tested this yet, but it's looking very good Thanks Lokasenna!
spk77 is offline   Reply With Quote
Old 06-15-2016, 11:24 AM   #11
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Posts: 272
Default

It's not possible to write JSFX plugins in Lua is it? I'd love to be able use this for FX as well, but I fear it's Eel or bust.
tack is offline   Reply With Quote
Old 06-09-2017, 12:08 PM   #12
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

Updated to version 1.0.

Lots of new features, new classes, bug fixes, efficiency improvements, 33% less sodium with the same great taste.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 06-28-2017, 07:40 AM   #13
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Quote:
Originally Posted by Lokasenna View Post
Updated to version 1.0.

Lots of new features, new classes, bug fixes, efficiency improvements, 33% less sodium with the same great taste.
very nice ! thanks a lot! will check this today
deeb is online now   Reply With Quote
Old 06-29-2017, 06:18 AM   #14
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

hello Lokasenna! could you provide some example how to call a simple checkbox like the one you have in the original post, with "are you a cool guy?" , .. i tried yesterday but with no success.

Also, in the github examples, you are calling example: req("Classes//Class - Slider.lua") which in OSX gives an error and we have to change to: req("Classes\Class - Slider.lua"), so probably this could be sorted with a separator variable depending on the system.
Thank you
deeb is online now   Reply With Quote
Old 06-29-2017, 07:34 AM   #15
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

also! you could a provide a way to , without changing the knob class, to not show the 100 in the image:

the knob is like this:
GUI.New("my_knob", "Knob", 1, 230, 32, 80, "Attack", 0, 100, 101, 0,0)

you say in comments:
vals Boolean. Display value labels?
For knobs with a lot of steps, i.e. Pan from -100 to +100, set this
to false and use a label to read the value, update the Knob's caption

I have seted it to false, but marks still showing and the 100 is just the last mark.
Is there an example too?

Cheers!
Attached Images
File Type: png Screen Shot 2017-06-29 at 15.29.55.png (11.5 KB, 472 views)
deeb is online now   Reply With Quote
Old 07-01-2017, 02:16 AM   #16
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

1. A single-item checkbox just requires making one with no overall caption, and only one option in the list. There's also an option I seem to have missed when I was documenting everything, .frame, that lets you disable the border around the list:
Code:
GUI.New("my_chk", "Checklist", 1, 16, 16, 200, 32, "", "Are you a cool guy?")

GUI.elms.my_chk.frame = false
2. Good catch. As it happens, you can use GUI.file_sep here:
Code:
local sep = GUI.file_sep
req("Classes"..sep.."Class - Slider.lua")
If I get a chance I'll update the examples with that.

3. Working fine here:
Code:
GUI.New("my_knob", "Knob", 1, 230, 32, 80, "Attack", 0, 100, 101, 0,0)

GUI.elms.my_knob.vals = false
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 07-01-2017, 03:10 AM   #17
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

Small update.

- Added the file separator check described above to all of the example files.

- Added a missing parameter to the Checklist documentation. .frame is a Boolean, defaults to True, and tells it whether or not to draw a frame around the list.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 07-20-2017, 05:28 PM   #18
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

nice Lokasenna ! meanwhile i noticed that when adding values of 10 ~ or more for padding , the checkbox and also the radio has strange behaviour you click on D , C gets some times checked, Click on C checks D same times, and so on Can you check if you get the same?




In example:
GUI.New("chklist", "Checklist",1, 30 ,20 , 100, 150, "","A,B,C,D","v", 20 )
Attached Images
File Type: png Screen Shot 2017-07-21 at 01.24.08.png (8.6 KB, 368 views)

Last edited by deeb; 07-20-2017 at 05:50 PM.
deeb is online now   Reply With Quote
Old 07-21-2017, 06:37 AM   #19
Flaneurette
Human being with feelings
 
Join Date: Dec 2016
Posts: 168
Default

Pretty cool. I am going to utilize this.

If there a way to include this lib, like a lib/include? or does it need to be in the same file as the other lua code? (still learning LUA)
__________________
👻 — for the reaper will come for all of us. 𓂀
Flaneurette is offline   Reply With Quote
Old 07-21-2017, 07:14 AM   #20
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Quote:
Originally Posted by Flaneurette View Post
Pretty cool. I am going to utilize this.

If there a way to include this lib, like a lib/include? or does it need to be in the same file as the other lua code? (still learning LUA)
in the GUI examples lokasenna did for us, he uses a custom function called "req". Probably you could check it.
deeb is online now   Reply With Quote
Old 07-21-2017, 08:48 AM   #21
Flaneurette
Human being with feelings
 
Join Date: Dec 2016
Posts: 168
Default

Quote:
Originally Posted by deeb View Post
in the GUI examples lokasenna did for us, he uses a custom function called "req". Probably you could check it.

Got it! the Example - General demonstration.lua explains it.
__________________
👻 — for the reaper will come for all of us. 𓂀
Flaneurette is offline   Reply With Quote
Old 07-21-2017, 10:05 AM   #22
Flaneurette
Human being with feelings
 
Join Date: Dec 2016
Posts: 168
Default

Lokasenna,

Is it possible to dump an (multidimensional) array/table inside a menu? would be cool. As I can see, it's only string right now.

Like:

Code:
GUI.New("my_mnu", "Menubox", 3, 256, 176, 64, 20, "Options:", MyArray)
Code:
MyArray = {
    {'FOO', 5},
    {'BAR', 2}
...etc 
}
__________________
👻 — for the reaper will come for all of us. 𓂀
Flaneurette is offline   Reply With Quote
Old 07-22-2017, 06:44 AM   #23
Flaneurette
Human being with feelings
 
Join Date: Dec 2016
Posts: 168
Default

Another thing that might be interesting. When filling a menubox with many items, it overflows:




But it does something strange too, it seems to repeat certain values at the bottom and grey them out:

__________________
👻 — for the reaper will come for all of us. 𓂀
Flaneurette is offline   Reply With Quote
Old 07-22-2017, 02:16 PM   #24
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

Quote:
Originally Posted by deeb View Post
nice Lokasenna ! meanwhile i noticed that when adding values of 10 ~ or more for padding , the checkbox and also the radio has strange behaviour you click on D , C gets some times checked, Click on C checks D same times, and so on Can you check if you get the same?




In example:
GUI.New("chklist", "Checklist",1, 30 ,20 , 100, 150, "","A,B,C,D","v", 20 )
I think the issue is that my check for "what option is the mouse over?" doesn't correct for padding at the top/bottom. Or something like that.

Will have a look.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 07-22-2017, 02:22 PM   #25
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

Quote:
Originally Posted by Flaneurette View Post
Lokasenna,

Is it possible to dump an (multidimensional) array/table inside a menu? would be cool. As I can see, it's only string right now.
It would much easier to do on your end than to build it into the GUI class, since I can't know what dimensions and indexing are being used for a user's table.

For the table listed above, you could do something like this (code might not be 100% correct, can't check it right now):

Code:
local function GetMenuItems()

  local str = ""

  for i = 1, #MyArray - 1 do
    str = str..MyArray[i][1]..","
  end

  -- This avoids an extra , at the end of the string
  str = str..MyArray[#MyArray][1]

  return str
end

...

GUI.New("my_mnu", "Menubox", 3, 256, 176, 64, 20, "Options:", GetMenuItems())
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 07-22-2017, 02:27 PM   #26
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

Quote:
Originally Posted by Flaneurette View Post
Another thing that might be interesting. When filling a menubox with many items, it overflows
There's no way (AFAIK) to restrict the menu's length or tell it to wrap to a second column - the menu itself is a function provided by Reaper. You should get little up/down arrows when it leaves the screen though.

Quote:
But it does something strange too, it seems to repeat certain values at the bottom and grey them out
Reaper's gfx.showmenu function uses specific prefixes for folders, graying out, etc, so that should only happen if a menu item starts with "#". See: https://www.extremraym.com/cloud/rea...a_gfx.showmenu

How are you generating the list? The Menubox class doesn't (well, shouldn't be) do anything with the list you give it aside from changing the commas to |s.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 07-23-2017, 06:20 AM   #27
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Quote:
Originally Posted by Lokasenna View Post
I think the issue is that my check for "what option is the mouse over?" doesn't correct for padding at the top/bottom. Or something like that.

Will have a look.
Yep seems something like that: Mouse Over is not being affected by The padding. Thank you lokasenna
deeb is online now   Reply With Quote
Old 07-23-2017, 06:41 AM   #28
Flaneurette
Human being with feelings
 
Join Date: Dec 2016
Posts: 168
Default

Quote:
Originally Posted by Lokasenna View Post
Reaper's gfx.showmenu function uses specific prefixes for folders, graying out, etc, so that should only happen if a menu item starts with "#". See: https://www.extremraym.com/cloud/rea...a_gfx.showmenu
Hah! Yes, I use # for sharps... that's hilarious. As if sharps aren't used in music... what was he thinking! lol.

So... how were going to use sharps? will it take unicode? escaping it with another sharp doesn't work...
__________________
👻 — for the reaper will come for all of us. 𓂀
Flaneurette is offline   Reply With Quote
Old 07-23-2017, 06:56 AM   #29
Flaneurette
Human being with feelings
 
Join Date: Dec 2016
Posts: 168
Default

Using the UTF-8 glyph seems to work: ♯

Or, a somewhat cleaner method:

Code:
utf8.char(9839)
__________________
👻 — for the reaper will come for all of us. 𓂀
Flaneurette is offline   Reply With Quote
Old 07-23-2017, 09:35 AM   #30
Flaneurette
Human being with feelings
 
Join Date: Dec 2016
Posts: 168
Default

Also made a custom adjustment/preference in the Menubox.lua.

Code:
290	local x, y = self.x, self.y
291	gfx.x, gfx.y = self.x, self.y + 20
or
Code:
290	self.__index = self
291	gfx.x, gfx.y = self.x, self.y + 20
instead of:

Code:
290	gfx.x, gfx.y = GUI.mouse.x, GUI.mouse.y
This way the dropdown will fit tightly next, and under the menubox instead of floating around wherever I click.
__________________
👻 — for the reaper will come for all of us. 𓂀
Flaneurette is offline   Reply With Quote
Old 07-23-2017, 03:10 PM   #31
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Would like to make a request, probably would be nice if elements like:

Menubox,
Checklist,
Radio,
even knobs

accept a function as argument like button does for onclick, but in this case for onselect, so that some actions could be maded based on this information immediatlly.


Thanks!!
deeb is online now   Reply With Quote
Old 07-24-2017, 07:02 PM   #32
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

You can do that easily yourself by rewriting the appropriate method for whichever element you want. i.e:

Code:
--Load all the classes

GUI.New("mnu_mymenu", "Menubox", ...whatever the Menubox params are...)

function GUI.elms.mnu_mymenu:onmouseup()

  -- Run the existing code for the menu
  -- This could be after your extra code instead if you want
  GUI.Menubox.onmouseup(self)

  DoMyStuff(self.retval)

end
Or, if you need to do that with multiple elements, you can easily create a new class based on Menubox and rewrite the method for that:

Code:
-- Load all your libraries

GUI.MyMenuBox = GUI.Menubox

function GUI.MyMenuBox:onmouseup()

  -- As above

end
See the example scripts for an, er, example of this in action. The code/formatting above might not be correct.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 07-27-2017, 10:06 AM   #33
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Quote:
Originally Posted by Lokasenna View Post
You can do that easily yourself by rewriting the appropriate method for whichever element you want. i.e:

Code:
--Load all the classes

GUI.New("mnu_mymenu", "Menubox", ...whatever the Menubox params are...)

function GUI.elms.mnu_mymenu:onmouseup()

  -- Run the existing code for the menu
  -- This could be after your extra code instead if you want
  GUI.Menubox.onmouseup(self)

  DoMyStuff(self.retval)

end
Or, if you need to do that with multiple elements, you can easily create a new class based on Menubox and rewrite the method for that:

Code:
-- Load all your libraries

GUI.MyMenuBox = GUI.Menubox

function GUI.MyMenuBox:onmouseup()

  -- As above

end
See the example scripts for an, er, example of this in action. The code/formatting above might not be correct.

Back to this! awesome
deeb is online now   Reply With Quote
Old 07-27-2017, 11:08 AM   #34
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Imagine this:
GUI.New("menu" ,"Menubox", 1, 1, 1, 250, 30, "", "A,B" )

How can i make this menu be defaulted to B when loading without changing the "A,B" string?

Thanks man!
deeb is online now   Reply With Quote
Old 07-28-2017, 02:42 PM   #35
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

GUI.Val can be used for both reading and setting elements' values:

Code:
GUI.New("menu" ,"Menubox",	1, 1,	1, 250, 30, "", "A,B" )
GUI.Val("menu", 2)
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack
Lokasenna is offline   Reply With Quote
Old 07-29-2017, 08:34 AM   #36
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Quote:
Originally Posted by deeb View Post
nice Lokasenna ! meanwhile i noticed that when adding values of 10 ~ or more for padding , the checkbox and also the radio has strange behaviour you click on D , C gets some times checked, Click on C checks D same times, and so on Can you check if you get the same?




In example:
GUI.New("chklist", "Checklist",1, 30 ,20 , 100, 150, "","A,B,C,D","v", 20 )
This is Whats is buggin me now . I'll try and see if i can fix ir later
deeb is online now   Reply With Quote
Old 07-29-2017, 08:36 AM   #37
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Is it possible without changing tab classe Tô have tabs with multiple rows?
deeb is online now   Reply With Quote
Old 07-29-2017, 02:53 PM   #38
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: The vast, frozen wasteland of western Canadia.
Posts: 4,209
Default

Quote:
Originally Posted by deeb View Post
This is Whats is buggin me now . I'll try and see if i can fix ir later
That would be awesome; I'm a couple of weeks away from having any time to fiddle with it myself.

Both of them use the same logic - Checklist in nmouseup and Radio in nmousedown:
Code:
	-- See which option it's on
	local mouseopt = self.dir == "h" 	and (GUI.mouse.x - (self.x + 0.5*self.chk_w))
										or	(GUI.mouse.y - (self.y + self.cap_h + self.pad) )
	mouseopt = mouseopt / ((self.chk_w + self.pad) * #self.optarray)
	mouseopt = GUI.clamp( math.floor(mouseopt * #self.optarray) + 1 , 1, #self.optarray )
Edit: I can't actually reproduce it on my end. If the checklist's height is too small then the last couple of options spill outside the frame and aren't clickable, but it appears to be properly detecting the option I'm over.

Quote:
Originally Posted by deeb View Post
Is it possible without changing tab classe Tô have tabs with multiple rows?
Not at the moment.
__________________
Currently working away from home; don't expect timely responses from me.
Default 5.0 Nitpicky Edition / GUI tutorial for Lua / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate / ReaPack

Last edited by Lokasenna; 07-29-2017 at 03:07 PM.
Lokasenna is offline   Reply With Quote
Old 07-29-2017, 03:03 PM   #39
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

ok! thanks ! all good meanwhile
deeb is online now   Reply With Quote
Old 07-29-2017, 05:21 PM   #40
deeb
Human being with feelings
 
Join Date: Feb 2017
Posts: 365
Default

Quote:
Originally Posted by Lokasenna View Post
You can do that easily yourself by rewriting the appropriate method for whichever element you want. i.e:

Code:
--Load all the classes

GUI.New("mnu_mymenu", "Menubox", ...whatever the Menubox params are...)

function GUI.elms.mnu_mymenu:onmouseup()

  -- Run the existing code for the menu
  -- This could be after your extra code instead if you want
  GUI.Menubox.onmouseup(self)






  DoMyStuff(self.retval)

end
Or, if you need to do that with multiple elements, you can easily create a new class based on Menubox and rewrite the method for that:

Code:
-- Load all your libraries

GUI.MyMenuBox = GUI.Menubox

function GUI.MyMenuBox:onmouseup()

  -- As above

end
See the example scripts for an, er, example of this in action. The code/formatting above might not be correct.

Thanks for your last edit, i will go to that part next
some days ago i had to use this:
Code:
function GUI.elms.menu1:onmouseup()
(...)
   GUI.Menubox.onmouseup(self)
end
and it worked.


but now i had the need to use this, to make the onmouse work for many elements:
Code:
function GUI.MyMenuBox:onmouseup()
    GUI.Menubox.onmouseup(self)
end
and i have an error: "stack overflow" on the console. I still didnt find how to solve! would be nice!


Edit: meanwhile i changed function GUI.Checklistnmouseup()and seems better now
Code:
local mouseopt = self.dir == "h" 	and (GUI.mouse.x - (self.x + 0.5*self.chk_w))
	 or	(GUI.mouse.y - (self.y + self.cap_h  ))
altho i don't like much that between checkboxes that space is always "clickable". . In this case for the checkbox before.But it is what it is ! it's great anyway.thank you

Last edited by deeb; 07-29-2017 at 08:13 PM.
deeb is online now   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 12:58 PM.


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