30

I am in need of help trying to get the ampersand character to show up in a Delphi XE6 VCL TActionMainMenuBar. I have come across similar requests on Stack Overflow but none that directly address the problem I am having.

When creating an action in the TActionManager, I need the caption of an action to read Network & Database. I have tried using two ampersands in the caption Network && Database to escape the accelerator which did not work. When I included two ampersands, I ended up with Network _Database (See Screenshot1). I have also set the property of ActionBar > Items > AutoHotKeys to false and ActionMainMenuBar > PersistentHotKeys to false. Doing so did not rectify the my issue.

Screenshot1

The one thing I did try out of pure desperation that I thought fixed it was to include four ampersands Network &&&& Database which when ran showed up as Network & Database (See Screenshot2). However during testing, if I were to press Alt to turn on hotkeys and navigate into the menu, the caption of the action would read Network && Database. I tried to include a screenshot of this however since I have less than 10 reputation points Stack Overflow limits my post to two attachments.

Screenshot2

If anyone can point me in the right direction of if I have left out some information please let me know. I've run out of ideas on how to fix this and I cannot come across anything similar when searching Google. Thanks in advance for the help.

zanussi
  • 1,286
  • 2
  • 22
  • 29
CKilpatrick
  • 313
  • 2
  • 8
  • 8
    [Vote](http://qc.embarcadero.com/wc/qcmain.aspx?d=109213). – Sertac Akyuz Feb 01 '17 at 23:59
  • 5
    Is it really *that* important to display `&` ? Why not simply use `Network and Database` or `Network / Database` ? I've just had a look through the menu items in a few apps (Notepad++, Visual Studio, just for example) and have yet to see anything other than `A and B`. No `&` anywhere. Perhaps you're fighting a battle that others have already decided just isn't worth it ? :) – Deltics Feb 02 '17 at 01:43
  • 5
    @Deltics It's only a battle because the RTL and VCL screw it up. System menus can do this. – David Heffernan Feb 02 '17 at 08:05
  • 4
    The [linked QC entry](http://qc.embarcadero.com/wc/qcmain.aspx?d=109213) for this bug contains a workaround. – mjn42 Feb 02 '17 at 14:08
  • @Deltics if it was up to me I would have to agree with you and just replace the ampersand with the word and. Unfortunately I was tasked to figure this out by my superior. – CKilpatrick Feb 02 '17 at 15:42
  • @mjn42 Thank you for the link. Very much appreciated. I will go ahead and give it a try and see how it works out. Again, thank you. – CKilpatrick Feb 02 '17 at 15:43
  • 2
    The code in the linked QC entry did resolve my issue. Surprised (not really) its still present in Berlin. @SertacAkyuz I didn't see your comment at first but I upvoted it. Thank you all for the help. This was driving me crazy. – CKilpatrick Feb 02 '17 at 16:18
  • @CKilpatrick - Yeah, it is a short comment, easy to miss. ;) You're welcome. – Sertac Akyuz Feb 02 '17 at 17:33
  • @David - the *reason* for a battle doesn't alter the fact that a battle is having to take place. One can only presume that the project manager of this particular project is in the luxurious position of not having any more important things to have their developers spend time on. If only we were all so lucky. :) But unless Notepad++, Visual Studio etc are all using the Delphi RTL/VCL there would appear to be *other* reasons for not using `&` in menus, even where there is no battle (or the battle perhaps remains, but for other reasons). – Deltics Feb 08 '17 at 00:41
  • 1
    FYI: http://www.probizwriters.com/PBW-blog/index.php/ampersand-usage/ (short version: `&` is not simply an alternative to/replacement for `and`) – Deltics Feb 08 '17 at 00:46

1 Answers1

2

You can fix it on your form's onshow event

action3.caption := 'Network &&Database';
Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
Tony Hanna
  • 91
  • 6