Why is the ampersand missing from the Firemonkey combo?
When you create a Delphi project and add combobox and install ComboBox1.Items.Add ('Zebra and Zulu') it shows "Zebra and Zulu" when you drop down the list. Perfect.
When you create a Firemonkey project and add a comboxbox or comboedit and install ComboBox1.Items.Add ("Zebra and Zulu") or ComboEdit1.Items.Add ("Zebra and Zulu") it shows "Zebra Zulu" (no ampersand shows), when you expand the list. However, when you select it with comboedit, the text box displays "Zebra and Zulu". It's just weird.
There is work now (sort of), but it's doubtful for me. Add a second ampersand and the dropdown shows the ampersand. However, the addition of a second ampersand appears in the comboedit portion of the field. Bad.
My question is, can you list the combo dropdowns to display the ampersand? And why is the ampersand missing in the first place?
source to share
It looks like this is a built-in behavior that is probably kept out of the way of VCL accelerator key handling. There seems to be no way to change this behavior with styles or parameters:
procedure TTextControl.DoChanged;
var
TextStr: string;
begin
if Assigned(FITextSettings) then
FITextSettings.TextSettings.BeginUpdate;
try
if Assigned(FITextSettings) then
FITextSettings.TextSettings.Assign(ResultingTextSettings);
TextStr := DelAmp(Text); // **! Here deleting ampersands unconditionally
if Assigned(FTextObject) then
begin
UpdateTextObject(FTextObject, TextStr);
// ... etc - method continues
One way to solve this problem is to use the full-width unicode ampersand:
ComboBox1.Items.Add('Zebra & Zulu');
Obviously, this does not apply to several reasons.
From the code above, this naturally affects all FMXs TTextControls
- even a TLabel
, for example, won't display the ampersand when assigned:
Label1.Text := 'Zebra & Zulu';
Even in a VCL app, for fun this:
Label1.Caption := 'Zebra & Zulu';
will display as
Zebra _Zulu
Although the VCL TComboBox
will correctly display an item with a single ampersand ...
This is an open QC, although in no rush:
source to share