|
|
|
03-26-2020, 11:42 AM
|
#1
|
Human being with feelings
Join Date: Jan 2014
Posts: 5,220
|
Close script windows with Esc?
I recently overhauled my Reaper setup and switched over from toolbars to the Radial Menu and ReaNoir colour swatch tool, and using the Quick Adder 2 for FX adding.
I would like to close these windows with Esc but they all seem to ignore the Esc key except for Radial Menu, I'm assuming this because they are script windows and the Esc key is hardwired to close Reaper floating windows... so does it require the script maker to define this function manually?
Any way I can close them with Esc whether it's scripted in or not?
|
|
|
03-26-2020, 12:04 PM
|
#2
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,859
|
Yeah, in case of Radial Menu, the key input handling is managed directly inside the script.
Here's a code snippet from the GUI.Main function:
Code:
-- (Escape key) (Window closed) (User function says to close)
if GUI.char == 27 or GUI.char == -1 or GUI.quit == true then
return 0
else
reaper.defer(GUI.Main)
end
I'm doing the same in my ReaLauncher script (which also uses Lokasenna's GUI as base).
So as far as I know, it comes down to the script maker to implement this behavior.
EDIT: Here are other examples using gfx.getchar: https://forum.cockos.com/showthread....41#post1785841
Last edited by solger; 03-26-2020 at 12:28 PM.
|
|
|
03-26-2020, 02:30 PM
|
#3
|
Human being with feelings
Join Date: Jan 2014
Posts: 5,220
|
So I suppose I should request this feature to the makers of ReaNoir and Quick Adder 2
In the mean time I have found the action ReaScript: Close all running Reascripts which I've assigned to Shift+esc. This is working quite well for me.
|
|
|
05-13-2020, 09:33 AM
|
#4
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Hey solger!
GUI.quit doesn't work for me. Is there anything I am missing?
I'm also using a Loka GUI.
|
|
|
05-13-2020, 09:58 AM
|
#5
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,859
|
Hi,
here's a short example:
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")()
if missing_lib then return 0 end
GUI.name = "GUI"
GUI.x, GUI.y, GUI.w, GUI.h = 0, 0, 640, 480
GUI.anchor, GUI.corner = "mouse", "C"
GUI.Main = function()
GUI.char = gfx.getchar()
-- if GUI.char > 0 then reaper.ShowConsoleMsg("\t" .. tostring(GUI.char) .. "\n") end
if GUI.char == 27 or GUI.char == -1 or GUI.quit == true then
return 0
else
reaper.defer(GUI.Main)
end
end
GUI.Init()
GUI.func = Main
GUI.freq = 0
GUI.Main()
Side note: looks like closing via ESC doesn't work when running the script from within Reaper's internal IDE window.
|
|
|
05-13-2020, 10:27 AM
|
#6
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Hmm, nope, doesn't work here. Is GUI.quit generated by the Loka GUI functions?
I couldn't find it in the Wiki.
|
|
|
05-13-2020, 10:46 AM
|
#7
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,859
|
Quote:
Originally Posted by _Stevie_
Hmm, nope, doesn't work here. Is GUI.quit generated by the Loka GUI functions?
I couldn't find it in the Wiki.
|
Yeah, if I remember correctly GUI.quit is part of the Core.lua from Loka's GUI. Another option would be to call gfx.quit() (instead of the 'return 0').
But not sure if GUI.quit might do some additional things (in comparison to gfx.quit.
Are you using v2 or v3 in this case?
The example is for v2. Not sure if something in this regards changed in v3 (hadn't had time yet to take a closer look).
If you like, you can also PM me your current script, so I can take a look at it.
|
|
|
05-13-2020, 10:47 AM
|
#8
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
|
Hey Solger, thanks, doing that!
|
|
|
08-18-2020, 04:13 AM
|
#9
|
Human being with feelings
Join Date: Sep 2008
Location: UK
Posts: 394
|
Hey, not necessarily entirely relevant to the specific discussion above, but I found this thread when searching for a problem I was having, so thought I'd write up here in case it's helpful for anyone looking in the future.
I'm using v3 aka Scythe.
I believe the default behaviour is that scripts will quit when you press Escape (or click the OS close button of the script GUI window).
However I needed to add another defer loop to mine, and this would carry on running even after the GUI closed. (A couple of side-notes here: (1) I know I can use GUI.func = foo, but for whatever reason this doesn't update fast enough for me. Possibly by design? (2) I guess having another defer loop might be a way of having a script that keeps running regardless of if its GUI is open? Not sure.)
My solution was to add the typical "keep running unless the window is closed or Esc is pressed" thing to my main defer loop.
Roughly speaking:
Code:
-- the usual Scythe boilerplate
...
local function mainloop()
...
local char = gfx.getchar()
if char ~= 27 and char ~= -1 then
reaper.defer(mainloop)
end
end
...
GUI.Main()
mainloop()
And with that, the script and GUI seems to successfully quit/exit when I press Esc or close the window, but I still have a nice fast defer loop running to do various things.
Hope this helps someone
|
|
|
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 04:20 PM.
|