|
|
|
10-20-2020, 06:23 PM
|
#1
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
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?
|
|
|
10-20-2020, 06:39 PM
|
#2
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
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")
|
|
|
10-21-2020, 10:45 AM
|
#3
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
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).
|
|
|
10-21-2020, 03:07 PM
|
#4
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
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.
|
|
|
10-21-2020, 03:13 PM
|
#5
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Haven't tested it, but I would try \z
|
|
|
10-21-2020, 03:14 PM
|
#6
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by amagalma
Haven't tested it, but I would try \z
|
Doesn't work...
|
|
|
10-21-2020, 03:19 PM
|
#7
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
What about \0
|
|
|
10-21-2020, 03:22 PM
|
#8
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by amagalma
What about \0
|
Nope, as \0 is seen as termination of the string.
Aka, menu ends there...
|
|
|
10-21-2020, 04:48 PM
|
#9
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
Quote:
Originally Posted by Meo-Ada Mespotine
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!
|
|
|
08-12-2023, 12:38 PM
|
#10
|
Human being with feelings
Join Date: Jul 2012
Posts: 43
|
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.
|
|
|
08-13-2023, 01:37 AM
|
#11
|
Human being with feelings
Join Date: Sep 2019
Posts: 1,134
|
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]','')
Last edited by Buy One; 08-13-2023 at 03:23 AM.
|
|
|
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 11:16 AM.
|