Multiline hints in Firemonkey

423 views Asked by At

I am trying to create multi line hint in my application made in delphi 10 seattle (FMX). seems like line break is not working while setting the hints.

Button1.Hint := 'Line 1' + #13#10 + 'Line2';

Any idea about how this can be done. this is working fine in VCL though.

2

There are 2 answers

1
Tomasz Andrzejewski On

please check if your button has ShowHint property checked.

  Button1.Hint := 'line 1' + sLineBreak + 'line 2';
0
Vic Fanberg On

I can offer a hint that I just worked through the same type of problem in C++ Builder Rio. I don't have Delphi, just C++ Builder, but the two products are so inter-related, I use hints (or code) from Delphi all the time to solve my problems.

In C/C++, you can generally use "\r" or its equivalent "\n\l" to display a carriage return (which I was trying to display in a TMemo). The TMemo looked like it was just stripping out the codes (except it thought the "\l", for line-feed, was an invalid escape code, so it would display just the "l") and was displaying everything on one line. I did notice the shortcut for tab ("\t") was working.

Again, in C/C++, there are other options for how to create characters. The equivalent of what you are doing, "char(13)+char(10)" just displays the characters "23" with everything on the same line (as you are describing). That is how one add characters when you are using decimal (base 10). If I wanted to use hexadecimal, I would write "\0xd\0xa" (which just gets stripped out of the text and displayed on one line, like the stuff in the second paragraph above).

The solution that I found that worked in C++ Builder was to use an octal notation for my character encoding ("\015\012"). Personally, in about 50 years of programming, I have never previously seen a situation where hexadecimal failed, but octal worked, but I was desperate enough to try it.

For all this testing and debugging, I created a new project, added a TMemo and a button (and set ShowHint=true for the button) to the form and put the following in for the code for the button:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    UnicodeString CR = "\015\012";
    Memo1->Text = "a" + CR + "b";
    Button1->Hint = Memo1->Text + " (hint)";
}

So, my solution to your problem is figure out how you can put octal codes in for characters and display the corresponding text in Delphi, then use that encoding for the octal characters "015" and "012".