Forum > LCL

[Solved] Is this behavior intentional or a bug?

(1/1)

Ten_Mile_Hike:

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TLabel treats '&' as if it is a TMenu item causing the '&' to be invisible and char that follows it to be underlinedwhereas TEdit displays '&' as the ampersand character itself. 

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);begin  Label1.caption:= '&'+'A';  Edit1.Caption := '&'+'A';end;      

dsiders:

--- Quote from: Ten_Mile_Hike on March 13, 2023, 04:18:19 am ---
--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TLabel treats '&' as if it is a TMenu item causing the '&' to be invisible and char that follows it to be underlinedwhereas TEdit displays '&' as the ampersand character itself. 

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);begin  Label1.caption:= '&'+'A';  Edit1.Caption := '&'+'A';end;      

--- End quote ---

It's called an accelerator or shortcut.
https://dsiders.gitlab.io/lazdocsnext/lcl/controls/tcontrol.caption.html

Ten_Mile_Hike:
@dsiders Thank you for your reply, however I knew that. That is why I mentioned that it was acting
like a Tmenu item (as an accelerator). My question, more succinctly, then is

"are TLabels supposed to be implementing accelerators as if it is a TMenu?"

And now I see that I NEVER KNEW TLabels had that functionality
T.Y.

Blaazen:
TLabel has property FocusControl where you can set some Edit, Combo etc. which is then focused when you use the accelerator.
If you need to display & in TCaption just write there double &, like "you && me".

Navigation

[0] Message Index

Go to full version