|
|
|
03-25-2020, 12:52 PM
|
#1
|
Banned
Join Date: Dec 2018
Posts: 642
|
Using Return key (ascii 13) to click a button in Lokasenna GUI
Is there a simple way to do this using the Lokasenna GUI?
I don't find any hooks for this in the code...
|
|
|
04-01-2020, 02:43 PM
|
#2
|
Banned
Join Date: Dec 2018
Posts: 642
|
Solved
Added this line of code to Core.lua in GUI.Main_Update_Sate:
Code:
GUI.char = gfx.getchar()
if GUI.char == 13 and GUI.ReturnSubmit then GUI.ReturnSubmit() end ---ADDED
Then in calling routine that sets up window:
Code:
local submit = GUI.New("submit", "Button", 1, 48, 200, 200, 20, "OK", getval)
GUI.ReturnSubmit = getval --- ADDED
|
|
|
04-01-2020, 05:59 PM
|
#3
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Hi cohler,
I'm not sure if I'm following you.
Are you saying that with your code I could have a GUI button respond to the Return key? So hitting "Return" would behave as if the button was clicked?
Thanks.
Cheers,
Andrew K
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
04-02-2020, 05:09 AM
|
#4
|
Banned
Join Date: Dec 2018
Posts: 642
|
Quote:
Originally Posted by Thonex
Hi cohler,
I'm not sure if I'm following you.
Are you saying that with your code I could have a GUI button respond to the Return key? So hitting "Return" would behave as if the button was clicked?
Thanks.
Cheers,
Andrew K
|
Yes, exactly.
|
|
|
04-02-2020, 06:45 AM
|
#5
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,450
|
Quote:
Originally Posted by cohler
Added this line of code to Core.lua in GUI.Main_Update_Sate:
Code:
GUI.char = gfx.getchar()
if GUI.char == 13 and GUI.ReturnSubmit then GUI.ReturnSubmit() end ---ADDED
Then in calling routine that sets up window:
Code:
local submit = GUI.New("submit", "Button", 1, 48, 200, 200, 20, "OK", getval)
GUI.ReturnSubmit = getval --- ADDED
|
If you add it in Core.lua then ALL scripts in your system that use Lokasenna's GUI will have it. Don't do it!
Add whatever you want in the GUI.func instead.
Code:
Function Whatever()
-- Check for ESC
-- Remind me to drink tea at 5 o clock
-- Free Willy
end
GUI.func = Whatever
|
|
|
04-02-2020, 08:34 AM
|
#6
|
Banned
Join Date: Dec 2018
Posts: 642
|
Quote:
Originally Posted by amagalma
If you add it in Core.lua then ALL scripts in your system that use Lokasenna's GUI will have it. Don't do it!
Add whatever you want in the GUI.func instead.
Code:
Function Whatever()
-- Check for ESC
-- Remind me to drink tea at 5 o clock
-- Free Willy
end
GUI.func = Whatever
|
The if statement added to Core.lua won't affect anything unless you define the function in your main code. That's why I wrote it that way. I don't see how your suggestion could even work.
You need to be checking for the return key in the function that is inside the GUI that checks for keystrokes, which is exactly what I did.
Pray tell with some actual code how your suggestion could possibly even work?
|
|
|
04-02-2020, 01:23 PM
|
#7
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by cohler
Yes, exactly.
|
Great!!
Bookmarked!
Thanks for sharing.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
|
|
|
04-02-2020, 02:04 PM
|
#8
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,450
|
Quote:
Originally Posted by cohler
The if statement added to Core.lua won't affect anything unless you define the function in your main code. That's why I wrote it that way. I don't see how your suggestion could even work.
You need to be checking for the return key in the function that is inside the GUI that checks for keystrokes, which is exactly what I did.
Pray tell with some actual code how your suggestion could possibly even work?
|
A GUI update by Lokasenna on ReaPack will overwrite your code in Core.lua.
Try this:
Code:
function MyFunc()
if GUI.char == GUI.chars.RETURN then reaper.ShowConsoleMsg("return\n") end
end
GUI.func = MyFunc
|
|
|
04-02-2020, 03:37 PM
|
#9
|
Banned
Join Date: Dec 2018
Posts: 642
|
Quote:
Originally Posted by amagalma
A GUI update by Lokasenna on ReaPack will overwrite your code in Core.lua.
Try this:
Code:
function MyFunc()
if GUI.char == GUI.chars.RETURN then reaper.ShowConsoleMsg("return\n") end
end
GUI.func = MyFunc
|
That does not do what my code does. That prints a message on the console when somebody calls GUI.func.
The code I gave executes the Submit button return function when a person presses the return key.
Totally different.
Lokasenna GUI V2 is not being updated anymore. But in any case, you don't need to get it from ReaPack, you can simply embed the code in your own system.
|
|
|
04-02-2020, 08:18 PM
|
#10
|
Banned
Join Date: Dec 2018
Posts: 642
|
Quote:
Originally Posted by amagalma
A GUI update by Lokasenna on ReaPack will overwrite your code in Core.lua.
Try this:
Code:
function MyFunc()
if GUI.char == GUI.chars.RETURN then reaper.ShowConsoleMsg("return\n") end
end
GUI.func = MyFunc
|
Tried this and it doesn't work. GUI.char does not maintain the keystroke data at this point in the code.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:33 AM.
|