Lazarus

Programming => Widgetset => Win32/64 => Topic started by: mdalacu on November 06, 2020, 04:31:48 pm

Title: TEdit.TextHint
Post by: mdalacu on November 06, 2020, 04:31:48 pm
Hi, i have obeserved that TextHint property is not working properly on Lazarus 2.0.8 on Win10.
Before if you had  Text:='' and ShowHint checked  The font in Editbox was italic and gray and was showing what you haad put in TextHint.
Now the text shows but with the same font as Text propery so you can not differetiate between hint and text...
Is the same for you, is it a bug, am i doing something wrong?
Thank you!
Title: Re: TEdit.TextHint
Post by: lucamar on November 06, 2020, 05:42:28 pm
It works as it should here (Laz/fpc 2.0.10/3.2.0, Linux-gtk2 x86_64) so it might be something widgetset-dependant or a bug that was fixed.
Title: Re: TEdit.TextHint
Post by: wp on November 06, 2020, 06:01:06 pm
For me (Win 10), the texthint is upright, too, but it is in some kind of gray color - I do agree that it is a bit difficult to discern. I went back to Laz 2.0.6, 2.0.2 and 1.8.4 and found that it always looks the same. Please specify the Laz version in which it was drawn italic.

Since the TextHint is drawn entirely by the widgetset on Windows I could imagine that one of the recent Windows updates changed the text hint behavior - just a gues...
Title: Re: TEdit.TextHint
Post by: mdalacu on November 07, 2020, 07:46:48 am
So, the lazarus Version is 2.0.8 and Windows version is 20.10.
I have pout two screenshots one the way it is now and one how it behaved in the past...
More greyed and italic....
Thanks.
Title: Re: TEdit.TextHint
Post by: lucamar on November 07, 2020, 08:50:25 am
Well, at least it's still gray. Looks like there has been some change in your Windows style/theme configuration, can it be? What happens if you try with a program compiled before the change?
Title: Re: TEdit.TextHint
Post by: mdalacu on November 07, 2020, 09:22:10 am
The picture on top is with the program compiled sometime in 2018 and the one below is how any editbox looks now.
I have no custom theme.
I have recompiled it now and  this is the way it looks...no italic, so it is very difficult to differentiate between normal text and a hint, especially on hi rez devices.
Title: Re: TEdit.TextHint
Post by: wp on November 07, 2020, 10:39:13 am
I should have gone back by one more version... When I test the issue with Laz 1.6.4 I do see the italic texthint, and there are additional properties TextHintFontColor and TextHintFontStyle. The svn commit notes of r53365 (Nov 14, 2016) say: "rewrite TextHint emulation, use WinAPI if available." This means that now the TextHint follows the Lazarus idea to use the widgetset as much as possible to control the appearance and behaviour of the controls. In widgetsets where the TEdit does not have a TextHint it is emulated., in the others (Win10, definitely) the native TextHint is used. I guess there is not much that can be done against it.
Title: Re: TEdit.TextHint
Post by: mdalacu on November 07, 2020, 10:42:55 am
Yes  wp, thank you for this. I was afraid of this...it was a nice and useful feature.
i also found this and deducted the same thing..:/

..from StdCtrls
Code: Pascal  [Select][+][-]
  1. initialization
  2.   RegisterPropertyToSkip(TCustomEdit, 'TextHintFontColor','Used in a previous version of Lazarus','');
  3.   RegisterPropertyToSkip(TCustomEdit, 'TextHintFontStyle','Used in a previous version of Lazarus','');
  4. end.  
 
Title: Re: TEdit.TextHint
Post by: JuhaManninen on November 07, 2020, 08:35:13 pm
Do other native Windows apps show the hint in Italic style? IOW, does the WinAPI somehow support it?

Title: Re: TEdit.TextHint
Post by: wp on November 07, 2020, 10:11:45 pm
Looking through several Microsoft applications which are on my system I only found upright texthints, the gray color seems to be noticeably brighter, though.

Juha, if I understand correctly, the LCL contains code to emulate the text hint for those widgetsets which do not support a native texthint. But then it should be possible the provide some kind of global switch to force using the emulated text hint if the user wants to. This would solve the OP's issue.
Title: Re: TEdit.TextHint
Post by: JuhaManninen on November 08, 2020, 11:19:33 am
The global switch could be just a compile time define. See the attached patch.
Then, should there be a property for FontStyle, or should the style always be Italic? It becomes more complicated.

[Edit] Oops, it should be IFNDEF obviously. Take it as a concept, I didn't test it.
Title: Re: TEdit.TextHint
Post by: Bart on November 08, 2020, 11:55:56 am
The problem with emulating TextHint (in the way I did in the first implementation of TextHint) is that when you change the font of the control when the TextHint is showing this will lead to unexpected results.
I did not see any solution for that.

In hindsight I think that implementing TextHintFontStyle and TextHintFontStyle was a mistake, it just overcomplicated things.
Italic and a little less font weight should be OK for any system that does not implement this natively.

Bart
Title: Re: TEdit.TextHint
Post by: JuhaManninen on November 08, 2020, 05:48:03 pm
Italic and a little less font weight should be OK for any system that does not implement this natively.
Italic sounds good because it is distinct from a text entered by user.
However many widgetsets, including WinAPI, don't use Italic. I don't know why.
LCL's policy is to use native widget behavior, thus logically native TextHint should be used when available.
Maybe the emulated one should be always Italic and a compile time define should force it to be emulated always. Patches, anyone?
Title: Re: TEdit.TextHint
Post by: Bart on November 08, 2020, 11:05:18 pm
Italic and a little less font weight should be OK for any system that does not implement this natively.
Italic sounds good because it is distinct from a text entered by user.
However many widgetsets, including WinAPI, don't use Italic. I don't know why.
LCL's policy is to use native widget behavior, thus logically native TextHint should be used when available.
Maybe the emulated one should be always Italic and a compile time define should force it to be emulated always. Patches, anyone?

I was talking about the emulated TextHint there.

Bart
TinyPortal © 2005-2018