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

View File

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