My problem: I have a custom inline subfolder display in popupmenu, I use non breaking spaces for indenting the deeper items. The is however not working on windows.
my function getNBSP(int n) below should return a non breaking indent
juce::String getNBSP(int n)
{
#if JUCE_WINDOWS
// on windows I have to for form the indent with a visible symbol, to avoid popupmenu
// discarding the whitespace.. Not good!
juce::String result="";
for(int t=0; t<n; t++) result.append(".",1);
return result;
#else
// this works on macos/ios, with the standard UTF-8 code for non breaking space
juce::CharPointer_UTF8 sp=juce::CharPointer_UTF8("\xc2\xa0");
juce::String result="";
for(int t=0; t<n; t++) result.appendCharPointer(sp);
return result;
#endif
}
still doesnt work in Juce 8.0.7 on windows:
I store the string including indent in a StringArray, which is fed into popmenu.addItem()
works on macos/ios. default font.
juce::String s=getNBSP(5); // make indent for subitem
auto f=deepresult.getFileName(); //get the item name
s.append(f,f.length()); // add it to indent
dispStrs.add(s); // add it to juce::StringArray which feeds popupmenu.addItem()
Please can you provide a simplified minimal example that demonstrates the problem youâre seeing? Ideally, start from a completely blank JUCE project and make the smallest changes necessary to trigger the issue.
Weâre unlikely to be able to help unless we can reproduce the same issue ourselves. As I showed above, drawFittedText seems to respect non-breaking spaces on Windows, and thatâs the same routine that PopupMenus use to draw text when using the LookAndFeel_V4. So, the issue doesnât seem to affect all uses of non-breaking spaces.
You said youâre using the default font - are you also using the default LookAndFeel, or have you customised the appearance of the PopupMenu somehow? Are you using custom menu item components? Have you tried drawing the same text outside of a PopupMenu, e.g. in your main app window, and do you see the same results there?
So it would seem that what you need to provide is an example project, that has nothing but a single popupmenu in it, done with the way that you populate your menus, demonstrating the issue.
@reuk@stephenk
I think I know what is happening: Iâm still at visual studio 2019
Because I tested in example MenusDemo:
I exchanged a menu item around line 390: result.setInfo( juce::CharPointer_UTF8 ("\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0RED"),"set the colour..","Outer",0);
It compiles ok, but: no whitespace.
So I think it needs VS2022, but today the site https://visualstudio.microsoft.com is unreachable from my place.
Can someone with VS2022 do a quick check with the MenusDemo example?
thanks for your guidance sofar..
I just tried it on Windows 10, VS2022, using your example juce::CharPointer_UTF8 ("\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0RED" for line 391 and it does NOT show any breaking spaces. I donât understand really how the version of VS would affect it anywayâŠ
However, Iâm not on the develop branch⊠Iâm on 8.0.4.
ok, so it seems that the non breaking spaces are deleted/disregarded somewhere in PopupMenu.
I have managed to update to VS2022 here too a couple of minutes ago , and it indeed doesnât matter, it doesnât work either.
The behaviour on develop (8.0.8) seems to be consistent with the behaviour from 7.0.12. So, this doesnât seem to be a regression.
On the develop branch, the text gets trimmed when creating a GlyphArrangement:
trim() eventually calls through to CharacterFunctions::isWhitespace() to determine the first non-whitespace character. This is implemented using the platform iswspace function, which seems to behave differently on macOS and Windows, and may also be affected by the current locale. On Windows, iswspace returns âtrueâ for a non-breaking space, but the same call returns false on macOS.
This has come up before:
Weâve now switched the implementation of GlyphArrangement to trim whitespace in the same way on all platforms. As a result, non-breaking spaces should now not be trimmed on any platform.
thanks for the fix!
how do I sync to this, since I guess this is not included in 8.0.8?
(never did an in between release JUCE update sofar, never use github)