allowed characters uiListBox #218
Replies: 11 comments 7 replies
-
Do you use string.char(arg)? So (") would become string.char(34) |
Beta Was this translation helpful? Give feedback.
-
I have the same issue since long. Using
Must be either a Juce issue or a Ctrlr issue. |
Beta Was this translation helpful? Give feedback.
-
As far as I can tell, those characters seem to break the xml-parser. The uiListbox skips the lineFeed when you use one of those characters. Even when you add a character like ' in the XML directly by doing: ' it just shows a "square" and it still skips the linefeed (
). Ok, after a search on the old forums. This is what Atom explained: There is a class "CharPointer" that seems to deal with UTF_8 and ASCII but while there is some mention about CharPointer in the LCore.cpp file with .def("getAddress", &CharPointer_UTF8::getAddress).. I couldn't get that to work. But more confusing is that the listbox uses "drawText" to output the text in the listbox. When you use drawText in a customComponent it shows those characters. Well, besides the " sign that breaks the string. And the \ needs to be doubled \ to show up. The reason one does break the code and the other doesn't is, I think, because the uiListBox puts/ gets its string in/ from a StringArray and the latter uiCustomComponent drawText gets painted on the fly without the string being taken from the StringArray. So you could try overriding with L&F or recreate the ListBox in a uiCustomComponent. But I guess your resolution to replace those characters is a lot less hassle. |
Beta Was this translation helpful? Give feedback.
-
You should be able to fix this with string.format("%q",). local m=MemoryBlock("42 61 63 6B 77 61 72 64 73 20 2A 36 30 27 73 20") -- Backwards *60's -- add to combo content local record=string.format("%q",m:toString()) panel:getComboComponent("myCombo"):setProperty("uiComboContent",record,false) It will surround everything with double quotes, but it works! |
Beta Was this translation helpful? Give feedback.
-
Thanks John,
Your solution using string.format("%q", s) works nicely and does
indeed solve my problem, but looks ugly :-)
I am considering using it. Good to have a choice.
MT
Op dinsdag 24 januari 2023 om 16:46:58 -0800 schreef John Goodland
***@***.***>:
…> I have experienced problems using certain characters in a uiListBox
> uiListBoxContent. In some of my panels I uses a uiListBox to display
> a list of patchnames. The characters that I found that give problems
> are:
>
> ASCII 34 (") ASCII 39 (') ASCII 44 (,) ASCII 61 (=)
>
> I have worked around the problem by writing some LUA code to replace
> these characters with a ".". But maybe someone knows a better
> solution to allow displaying such characters in a uiListBox? I don't
> need complete Unicode support for this purpose, but would be happy
> enough with 7 bits ASCII support for ASCII characters 32 to 126.
>
I think you can fix this with *string.format("%q",)*.
local m=MemoryBlock(" 42 61 63 6B 77 61 72 64 73 20 2A 36 30 27 73
20") -- Backwards *60's
-- add to combo content
local record=string.format("%q",m:toString())
panel:getComboComponent("myCombo"):setProperty("uiComboContent",record,false)
It will surround everything with double quotes, but it works!
—
Reply to this email directly, view it on GitHub
<#218 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2YYOAXFLHTJTKO7YN37I3WUBZYFANCNFSM4ZSW6Q2Q>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
One small problem still occurs with patchsnames that have a doublequote
in it.
A patche that I have named
Say "Hi!"
will be displayed as
"Say \"Hi!\""
which is ugly, but at least it won't break my uiListBox.
MT
Op woensdag 25 januari 2023 om 00:08:16 -0800 schreef John Goodland
***@***.***>:
… I agree, but it does fix a common problem! I only just stumbled on
it! I think it's unique to /lua/.
<https://pgl.yoyo.org/luai/i/string.format>
—
Reply to this email directly, view it on GitHub
<#218 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2YYOHEDZPUMSZRV3PB4VDWUDNPBANCNFSM4ZSW6Q2Q>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi Martin, In that case probably about the only thing I can think of is to substitute the " for a '! -- -- Called when a mouse is down on this component -- myMethod = function(--[[ CtrlrComponent --]] comp --[[ MouseEvent --]], event) local myList = "" local t = {'Hi there "everyone"', "60's are cool", "It's complex!", ' Say "Hi"'} for _, v in ipairs(t) do local parsed = string.gsub(v, '"', "'") myList = string.format("%s\n%q", myList, parsed) end panel:getComboComponent("c"):setProperty("uiComboContent", myList, false) end [escape text for combo_1_0.zip](https://github.com/RomanKubiak/ctrlr/files/10498173/escape.text.for.combo_1_0.zip) |
Beta Was this translation helpful? Give feedback.
-
Yep, that's what I did.
Op woensdag 25 januari 2023 om 02:01:25 -0800 schreef John Goodland
***@***.***>:
… Hi Martin,
In that case probably about the only thing I can think of is to
substitute the " for a '!
--
-- Called when a mouse is down on this component
--
myMethod = function(--[[ CtrlrComponent --]] comp --[[ MouseEvent
--]], event)
local myList = ""
local t = {'Hi there "everyone"', "60's are cool", "It's
complex!", ' Say "Hi"'}
for _, v in ipairs(t) do
local parsed = string.gsub(v, '"', "'")
myList = string.format("%s\n%q", myList, parsed)
end
panel:getComboComponent("c"):setProperty("uiComboContent",
myList, false)
end
[escape text for
combo_1_0.zip](https://github.com/RomanKubiak/ctrlr/files/10498173/escape.text.for.combo_1_0.zip)
—
Reply to this email directly, view it on GitHub
<#218 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2YYOEDAK43MLFRG4PRBCTWUD2XLANCNFSM4ZSW6Q2Q>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I had "borrowed" code from another panel to replace problematic characters in variable s with a backtick before loading preset names into the bank listbox: s = s:gsub('[="\']', '`') The backtick gets displayed in the listbox which shows all preset names in a bank of presets, but I'm preserving the original character in the saved preset data (in a panel variable). Sounds like I need to replace commas also. |
Beta Was this translation helpful? Give feedback.
-
I'm using:
|
Beta Was this translation helpful? Give feedback.
-
This issue will probably be fixed in version 5.6.34 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have experienced problems using certain characters in a uiListBox uiListBoxContent. In some of my panels I uses a uiListBox to display a list of patchnames. The characters that I found that give problems are:
ASCII 34 (")
ASCII 39 (')
ASCII 44 (,)
ASCII 61 (=)
I have worked around the problem by writing some LUA code to replace these characters with a ".". But maybe someone knows a better solution to allow displaying such characters in a uiListBox? I don't need complete Unicode support for this purpose, but would be happy enough with 7 bits ASCII support for ASCII characters 32 to 126.
Beta Was this translation helpful? Give feedback.
All reactions