Recent

Author Topic: [Solved] Is this behavior intentional or a bug?  (Read 531 times)

Ten_Mile_Hike

  • Jr. Member
  • **
  • Posts: 50
[Solved] Is this behavior intentional or a bug?
« on: March 13, 2023, 04:18:19 am »
Code: Text  [Select][+][-]
  1. TLabel treats '&' as if it is a TMenu item causing the '&' to be invisible and char that follows it to be underlined
  2. whereas TEdit displays '&' as the ampersand character itself.
  3.  

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   Label1.caption:= '&'+'A';
  4.   Edit1.Caption := '&'+'A';
  5. end;
  6.  
     
« Last Edit: March 13, 2023, 05:30:58 am by Ten_Mile_Hike »

dsiders

  • Hero Member
  • *****
  • Posts: 1084
Re: Is this behavior intentional or a bug?
« Reply #1 on: March 13, 2023, 04:46:56 am »
Code: Text  [Select][+][-]
  1. TLabel treats '&' as if it is a TMenu item causing the '&' to be invisible and char that follows it to be underlined
  2. whereas TEdit displays '&' as the ampersand character itself.
  3.  

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   Label1.caption:= '&'+'A';
  4.   Edit1.Caption := '&'+'A';
  5. end;
  6.  
     

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

Ten_Mile_Hike

  • Jr. Member
  • **
  • Posts: 50
Re: Is this behavior intentional or a bug?
« Reply #2 on: March 13, 2023, 05:04:32 am »
@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.
« Last Edit: March 13, 2023, 05:06:50 am by Ten_Mile_Hike »

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: Is this behavior intentional or a bug?
« Reply #3 on: March 13, 2023, 05:14:26 am »
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".
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

 

TinyPortal © 2005-2018