lcl: in TCustomEdit, replaces Text property check for CanShowTextHint before showing text hint. Move the logic to hide the text hint from RealSetText to TextChanged

git-svn-id: trunk@53296 -
This commit is contained in:
blikblum 2016-11-04 11:58:36 +00:00
parent eb95373456
commit 1c88d48964
2 changed files with 16 additions and 9 deletions

View File

@ -117,7 +117,7 @@ end;
procedure TCustomEdit.Loaded; procedure TCustomEdit.Loaded;
begin begin
inherited Loaded; inherited Loaded;
if (Text = '') then ShowTextHint; if CanShowTextHint then ShowTextHint;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -535,7 +535,6 @@ end;
procedure TCustomEdit.RealSetText(const AValue: TCaption); procedure TCustomEdit.RealSetText(const AValue: TCaption);
begin begin
FTextChangedByRealSetText := True; FTextChangedByRealSetText := True;
if FTextHintShowing and (not FSettingTextHint) then HideTextHint;
Modified := False; Modified := False;
inherited RealSetText(AValue); inherited RealSetText(AValue);
FTextChangedByRealSetText := False; FTextChangedByRealSetText := False;
@ -591,7 +590,16 @@ begin
Change; Change;
end; end;
end; end;
if CanShowTextHint and (not FTextHintShowing) then ShowTextHint; if FTextHintShowing then
begin
if not FSettingTextHint and not CanShowTextHint then
HideTextHint;
end
else
begin
if CanShowTextHint then
ShowTextHint;
end;
end; end;
procedure TCustomEdit.Change; procedure TCustomEdit.Change;
@ -616,7 +624,7 @@ procedure TCustomEdit.DoExit;
begin begin
FAutoSelected := False; FAutoSelected := False;
inherited DoExit; inherited DoExit;
if (Text = '') then ShowTextHint; if CanShowTextHint then ShowTextHint;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -636,7 +644,7 @@ begin
Result:=fCaretPos; Result:=fCaretPos;
end; end;
procedure TCustomEdit.SetTextHint(AValue: TTranslateString); procedure TCustomEdit.SetTextHint(const AValue: TTranslateString);
begin begin
if (FTextHint = AValue) then Exit; if (FTextHint = AValue) then Exit;
FTextHint := AValue; FTextHint := AValue;
@ -646,7 +654,7 @@ begin
end end
else else
begin begin
if (Text = '') then ShowTextHint; if CanShowTextHint then ShowTextHint;
end; end;
end; end;
@ -654,8 +662,7 @@ procedure TCustomEdit.ShowTextHint;
var var
OldModified: Boolean; OldModified: Boolean;
begin begin
if not CanShowTextHint then Exit; if not FTextHintShowing then
if not FtextHintShowing then
begin begin
FSavedFontColor := Font.Color; FSavedFontColor := Font.Color;
FSavedFontStyle := Font.Style; FSavedFontStyle := Font.Style;

View File

@ -754,7 +754,7 @@ type
procedure SetSelLength(Val: integer); virtual; procedure SetSelLength(Val: integer); virtual;
procedure SetSelStart(Val: integer); virtual; procedure SetSelStart(Val: integer); virtual;
procedure SetSelText(const Val: string); virtual; procedure SetSelText(const Val: string); virtual;
procedure SetTextHint(AValue: TTranslateString); virtual; procedure SetTextHint(const AValue: TTranslateString); virtual;
function ChildClassAllowed(ChildClass: TClass): boolean; override; function ChildClassAllowed(ChildClass: TClass): boolean; override;
class function GetControlClassDefaultSize: TSize; override; class function GetControlClassDefaultSize: TSize; override;
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer); override;