Lazarus

Programming => LCL => Topic started by: kinlion on March 05, 2021, 07:51:22 am

Title: TLabeledEdit does not show TextHint when it is ReadOnly or not Enabled
Post by: kinlion on March 05, 2021, 07:51:22 am
As title.

Maybe TEdit is same, but I did not test.

Is it a bug or just designed in such a way?

I have a TLabeledEdit to show a parameter, if user did not input the value(the parameter is empty), I want it shows the default value by TextHint.
However, the parameter is not editable at some time. Thus I make the LabeledEdit ReadOnly or not Enabled, then the TextHint becomes invisible.

Environment:
Win10 x64
Lazarus 2.0.10
FPC 3.2.0
SVN Revision: 63526

Any help will be appreciated.
Title: Re: TLabeledEdit does not show TextHint when it is ReadOnly or not Enabled
Post by: ASerge on March 05, 2021, 02:52:13 pm
I have a TLabeledEdit to show a parameter, if user did not input the value(the parameter is empty), I want it shows the default value by TextHint.
However, the parameter is not editable at some time. Thus I make the LabeledEdit ReadOnly or not Enabled, then the TextHint becomes invisible.
In my opinion, this is normal. If this is a hint and not a label, then since the field cannot be edited, the hint is not needed either.
Title: Re: TLabeledEdit does not show TextHint when it is ReadOnly or not Enabled
Post by: Bart on March 05, 2021, 08:17:07 pm
On Windows TextHint is implemented natively using the Windows API for that.
So, what you see is the natural behaviour of Windows.

Bart
Title: Re: TLabeledEdit does not show TextHint when it is ReadOnly or not Enabled
Post by: jamie on March 06, 2021, 12:01:41 am
use something like this instead of disabling it etc..

Code: Pascal  [Select][+][-]
  1. procedure TForm1.LabeledEdit1KeyDown(Sender: TObject; var Key: Word;
  2.   Shift: TShiftState);
  3. begin
  4.   if Key <> VK_TAB Then Key := 0;
  5. end;                                            
  6.  

Setup some flag somewhere to turn it on/off
Title: Re: TLabeledEdit does not show TextHint when it is ReadOnly or not Enabled
Post by: winni on March 06, 2021, 12:44:08 pm
Hi!

If TabStop is enabled pressing Tab never reaches the onKey events.

Winni
Title: Re: TLabeledEdit does not show TextHint when it is ReadOnly or not Enabled
Post by: jamie on March 06, 2021, 03:52:38 pm
Yes you got me on that one...

I guess if I was using Lazarus more often I would of noticed that.. . :)
TinyPortal © 2005-2018