Old 10-20-2020, 06:23 PM   #1
jkooks
Human being with feelings
 
Join Date: May 2020
Posts: 190
Default gfx.showmenu Escape Characters

Are there any escape characters for the gfx.showmenu options? Say one of the menus starts with "#" or "!" - is there any way to not have it gray out the option or check it since it is part of the menu option without removing that character or having to add something before it?
jkooks is online now   Reply With Quote
Old 10-20-2020, 06:39 PM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

I'm not sure, what you want to achieve. If you don't want it to be greyed out or checked, simply don't add the special characters in front of the menu-name...

Code:
gfx.init()
A=gfx.showmenu("First entry|second entry")
Edit: or do you want to gray them/check out only under certain conditions? In that case, you need to insert the # or !

Code:
condition=reaper.MB("Shall first entry be greyed?", "", 4)

if condition==6 then -- if yes was selected, set variable grey to # else keep it empty
  grey="#"
else
  grey=""
end

gfx.init()

-- insert variable grey before the menuentry-text
A=gfx.showmenu(grey.."First entry|second entry")
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-21-2020, 10:45 AM   #3
jkooks
Human being with feelings
 
Join Date: May 2020
Posts: 190
Default

It is more so in order to display results that may have the certain character at the front of it. For example, in a find and replace script that I made you can search for something like "!char" and it will add it to a dropdown menu that displays the history of your searches. By adding it, however, the entry will automatically be check marked because of the "!" at the front.

So I was essentially just wondering if there was a designated escape character that will tell the gfx.showmenu method to not checkmark that entry as long as it is before the "!" (or the same for the other special characters properties) because the script recognizes that character is telling it to not do the usual stuff when a "!" is at the front of the script.

I know this can be done by me just adding something before any entry that starts with a special character ("<", ">", "!", "#") but I was curious to see if there was a specific character that already had that function designated, as well as one that the script knew to remove before it displayed the contents of the menu (for example - if "" means to ignore the "!" and not automatically checkmark it, the function would know to remove the "" at the front of "\!char" because the actual entry is only "!char" and the "" is just there to tell me to not check the entry).
jkooks is online now   Reply With Quote
Old 10-21-2020, 03:07 PM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Easiest is like you said adding something.
I did some testing and a simple space works.
So if you give all entries a space in the beginning, it doesn't look weird and works the way you want.

Lua's own % as escape character does not work unfortunately.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-21-2020, 03:13 PM   #5
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Haven't tested it, but I would try \z
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-21-2020, 03:14 PM   #6
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by amagalma View Post
Haven't tested it, but I would try \z
Doesn't work...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-21-2020, 03:19 PM   #7
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

What about \0
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-21-2020, 03:22 PM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by amagalma View Post
What about \0
Nope, as \0 is seen as termination of the string.
Aka, menu ends there...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-21-2020, 04:48 PM   #9
jkooks
Human being with feelings
 
Join Date: May 2020
Posts: 190
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Easiest is like you said adding something.
I did some testing and a simple space works.
So if you give all entries a space in the beginning, it doesn't look weird and works the way you want.

Lua's own % as escape character does not work unfortunately.
Yeah, that is what I found as well. A space works fine for my purposes, I was just curious if someone knew about a character for this purpose that was omitted from the API.

Thanks for testing out all the other characters!
jkooks is online now   Reply With Quote
Old 08-12-2023, 12:38 PM   #10
soulaccess
Human being with feelings
 
soulaccess's Avatar
 
Join Date: Jul 2012
Posts: 43
Default ampersand '&' works

For me, it works to use the ampersand '&' to escape these characters: '<>!#&'.
Unfortunately it does not work for the pipe character '|'.
This works in REAPER's API and even in JSFX.
Code:
A=gfx_showmenu("&#First entry|&!Second entry|&&Third entry|&<Fourth entry|&>Fifth entry")
// displays as: #First entry
//              !Second entry
//              &Third entry
//              <Fourth entry
//              >Fifth entry
Would be great the pipe character could be escaped as well, but probably it's just not implemented or a bug.

Last edited by soulaccess; 08-13-2023 at 03:05 AM.
soulaccess is offline   Reply With Quote
Old 08-13-2023, 01:37 AM   #11
Buy One
Human being with feelings
 
Buy One's Avatar
 
Join Date: Sep 2019
Posts: 1,134
Default

Ampersand is a special character in its own right, used as a quick access shortcut, although it's not listed in the gfx.showmenu() description

I replace the pipe character with ㅣ (Hangul character for vowel /i/, U+3163 Hangul I).

This character │ (U+2502, box drawings light vertical), could also be used i guess.

If the text length needs to be counted with these, their extra bytes must be discarded from the copy of the string to avoid botching the original one
Code:
#mystring_copy:gsub('[\128-\191]','')
__________________
https://github.com/Buy-One/REAPER-scripts (175)
REAPER is a DAW whose user guide file is larger than its installation file

Last edited by Buy One; 08-13-2023 at 03:23 AM.
Buy One 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 11:16 AM.


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