|
|
|
05-19-2018, 03:28 PM
|
#1
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Reascript Momentary Message Box?
Hi fellow scripters,
Is there a function or way to invoke a temporary message box or similar?
For example, if I run a certain type of script, I'd like to be able to have a certain message upon completion that I do not have to click OK on.
A real-life example would be if I forgot to select items and the scrip won't do anything unless there are selected items, it would be nice to have a message box pop up for a second saying:
"Nothing happened! No items were selected"
Is this possible?
Thanks in advance.
Cheers,
Andrew K
Last edited by Thonex; 05-19-2018 at 04:22 PM.
|
|
|
05-19-2018, 05:11 PM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
|
There's Help_Set: reaper.Help_Set('Hello World!', true). ShowConsoleMsg can display a message on a modeless window.
For a true temporary message box you can design your own using gfx.
|
|
|
05-19-2018, 06:31 PM
|
#3
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Code:
local timer = 2 -- Time in seconds
local msg_title = "Done!"
local msg_str = "Nothing happened - no items were selected."
local wnd_w, wnd_h = 400, 125
-- Get the screen size
local __, __, scr_w, scr_h = reaper.my_getViewport(0, 0, 0, 0, 0, 0, 0, 0, 1)
-- Reference time to check against
local time = os.time()
-- Window background
gfx.clear = reaper.ColorToNative(255,255,255)
-- Open the window
-- Name w h dock x y
gfx.init(msg_title, wnd_w, wnd_h, 0, (scr_w - wnd_w) / 2, (scr_h - wnd_h) / 2)
gfx.setfont(1, "Arial", 18)
-- Black
gfx.set(0, 0, 0, 1)
-- Center the text
local str_w, str_h = gfx.measurestr(msg_str)
local txt_x, txt_y = (gfx.w - str_w) / 2, (gfx.h - str_h) / 2
local function Main()
-- Get the keyboard/window state
local char = gfx.getchar()
-- Reasons to end the script:
-- Esc Window closed Timer is up
if char == 27 or char == -1 or (os.time() - time) > timer then return end
-- Center the text
gfx.x, gfx.y = txt_x, txt_y
gfx.drawstr(msg_str)
-- Maintain the window and keep the script running
gfx.update()
reaper.defer(Main)
end
Main()
|
|
|
05-20-2018, 02:18 AM
|
#4
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Wow guys!!
Just wow!
Thanks so much for this.
This goes a little deeper than I though I would need... but thanks so much Lokasenna for that coding example. I got back late (2:15 am here in LA) and I'll look at it with fresh eyes after a good night's sleep.
Here's hoping I can wrap this nicely into a function and only have to "understand it" breiefly enough to get it to work
Thanks again... and you too cfillion, thanks for that Set_Help ... never would have found that. Will check it out also.
Cheers,
Andrew K
|
|
|
05-20-2018, 04:06 PM
|
#5
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Just wanted to thanks you guys again.
Works 100%!!
I'm hoping Lokasenna already had that code handy and just inserted my "message".. I'd feel bad if he coded that simply on my account. :O
Then again... THANKS... because it works perfectly.
Cheers,
Andrew K
|
|
|
05-20-2018, 05:37 PM
|
#6
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by Thonex
I'm hoping Lokasenna already had that code handy and just inserted my "message".. I'd feel bad if he coded that simply on my account. :O
|
I've probably spent too much time fiddling with GUI stuff; I wrote that from memory and then just had to run it a couple of times to work out the typos. Glad to help.
|
|
|
05-20-2018, 09:00 PM
|
#7
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by Lokasenna
I've probably spent too much time fiddling with GUI stuff; I wrote that from memory and then just had to run it a couple of times to work out the typos. Glad to help.
|
Thanks Lokasenna! I can't do anything form the top of my head... LOL
Speaking of typos, what is the most recent Sublime Text Reascript module? I see this one but it's from 4 years ago... that seems ancient in Reaper years...
https://packagecontrol.io/packages/ReaSyntax
Also, is there a way to integrate Sublime into Reaper as it's default development environment? If so, where can I learn more on how to do this?
Cheers,
Andrew K
|
|
|
05-20-2018, 09:05 PM
|
#8
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
That's the most recent one I can find too. I use Notepad++, but X-Raym's syntax module for it isn't much more up to date.
As for IDE integration... nope.
|
|
|
05-20-2018, 09:24 PM
|
#9
|
Human being with feelings
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
|
Quote:
Originally Posted by Lokasenna
That's the most recent one I can find too. I use Notepad++, but X-Raym's syntax module for it isn't much more up to date.
As for IDE integration... nope.
|
Thanks for saving me the time! Oh yeah... IDE ... that's the acronym I was looking for
Cheers,
Andrew K
|
|
|
02-04-2022, 04:52 PM
|
#10
|
Banned
Join Date: Dec 2018
Posts: 642
|
Quote:
Originally Posted by Lokasenna
Code:
local timer = 2 -- Time in seconds
local msg_title = "Done!"
local msg_str = "Nothing happened - no items were selected."
local wnd_w, wnd_h = 400, 125
-- Get the screen size
local __, __, scr_w, scr_h = reaper.my_getViewport(0, 0, 0, 0, 0, 0, 0, 0, 1)
-- Reference time to check against
local time = os.time()
-- Window background
gfx.clear = reaper.ColorToNative(255,255,255)
-- Open the window
-- Name w h dock x y
gfx.init(msg_title, wnd_w, wnd_h, 0, (scr_w - wnd_w) / 2, (scr_h - wnd_h) / 2)
gfx.setfont(1, "Arial", 18)
-- Black
gfx.set(0, 0, 0, 1)
-- Center the text
local str_w, str_h = gfx.measurestr(msg_str)
local txt_x, txt_y = (gfx.w - str_w) / 2, (gfx.h - str_h) / 2
local function Main()
-- Get the keyboard/window state
local char = gfx.getchar()
-- Reasons to end the script:
-- Esc Window closed Timer is up
if char == 27 or char == -1 or (os.time() - time) > timer then return end
-- Center the text
gfx.x, gfx.y = txt_x, txt_y
gfx.drawstr(msg_str)
-- Maintain the window and keep the script running
gfx.update()
reaper.defer(Main)
end
Main()
|
Thanks for this, but it draws all the text as graphics. What if you want text as text that is selectable, copyable, etc...?
It is also not useful for visually impaired as screen readers cannot read this...
|
|
|
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 08:57 AM.
|