Ampersand (&) character stripped from menu item names

I just noticed that if I create a custom menu item, or sub-menu on the application menus or as a context menu, that contains an ampersand (&) character then it is stripped-out when the menu is displayed.
Does anybody know if this is an intended behaviour or an odd glitch and if so is there a way to display an ampersand in the menu item?

It’s not crucial, just slightly irksome, but I’m generating custom context menu items according to user inputs and if they noticed a character was missing they might want to know why…

Seems to occur on both SU 2016 (Mac) and SU 2013 (Mac) from the spot tests I’ve done so far, so presumably not a new issue.


It’s not a glitch - most programming stuff uses the ampersand before a character in a menu item to indicate that it’s a keystroke to execute that menu option. (Note that it should be underlined automatically too.)
If you use character codes then it should work (or I think double ampersand works?)

It doesn’t work that way in SketchUp menus on the Mac. Does it work on Windows? The ampersand character simply disappears, including when doubled and when it initiates an HTML escape sequence such as ‘&’ (which is the sequence for ‘&’). The character following the & is not underlined and does not become a keystroke to invoke the menu item. I haven’t been able to find an encoding that causes a ‘&’ to appear.

Thanks both,
Yes I agree, the underlining is a Win behaviour and the ampersand does not seem to have that effect on Mac (shortcut keys are typically displayed to the right of the menu item name in Mac apps).

I also tried the double-ampersand and it has no effect.

With quotable printable encoding other characters work but the ‘&‘s still just disappear…
test_menu.add_item(“TEST \x25\x26\x27”) {puts "TEST %&’"} => "TEST %’" in menu item


have you tried putting the text in a variable?

If you double up the & as && it puts one & into a menu string - at least in Windows - no access to a MAC at the moment, so I can’t test it…

"Cat & Dogs"   >> "Cats Dogs"
"Cat && Dogs"  >> "Cat & Dogs"

Tested it on Mac. Double doesn’t work. Both of them vanish!

On a MAC one & makes the following character the ‘accelerator’ key [but not with OSX ?]
I.E. underlining the character after it too.

As far as I can see, on a MAC doubling up to && should insert a single & in the text ?
Just like on PCs ?? e.g.

Yes, not on OS X. So this will work only on ancient Mac platforms that SketchUp doesn’t support :smirk:

The page you reference says a double ampersand should insert a single, but that did not work when I tried it in SketchUp. Since the menus to which you can add items via Ruby are necessarily dynamic, SketchUp has to contain code, both Ruby and C++, to do the addition. It seems likely that the loss of the double ampersand happens as the label string flows through this code - though I have no idea why.