mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:19:19 +02:00
Fix firing an OnChange and setting Modified when setting Text inside OnChange and new Text = old Text. Issue #0032602.
git-svn-id: trunk@56181 -
This commit is contained in:
parent
9823f61682
commit
c5637ad72a
@ -81,7 +81,7 @@ begin
|
||||
BorderStyle := bsSingle;
|
||||
FAutoSelect := True;
|
||||
FAutoSelected := False;
|
||||
FTextChangedByRealSetText := False;
|
||||
FTextChangedByRealSetTextCounter := 0;
|
||||
AutoSize := True;
|
||||
// Accessibility
|
||||
AccessibleRole := larTextEditorSingleline;
|
||||
@ -548,10 +548,11 @@ begin
|
||||
if (FEmulatedTextHintStatus=thsShowing) and (AValue<>'') then
|
||||
HideEmulatedTextHint;
|
||||
|
||||
FTextChangedByRealSetText := True;
|
||||
Inc(FTextChangedByRealSetTextCounter);
|
||||
Modified := False;
|
||||
inherited RealSetText(AValue);
|
||||
FTextChangedByRealSetText := False;
|
||||
Dec(FTextChangedByRealSetTextCounter);
|
||||
if (FTextChangedByRealSetTextCounter < 0) then FTextChangedByRealSetTextCounter := 0;
|
||||
|
||||
if (FEmulatedTextHintStatus=thsHidden) and CanShowEmulatedTextHint then
|
||||
ShowEmulatedTextHint;
|
||||
@ -601,7 +602,7 @@ begin
|
||||
begin
|
||||
if ([csLoading,csDestroying]*ComponentState=[]) then
|
||||
begin
|
||||
if not FTextChangedByRealSetText then
|
||||
if (FTextChangedByRealSetTextCounter = 0) then
|
||||
Modified := True;
|
||||
Change;
|
||||
end;
|
||||
|
@ -8297,7 +8297,11 @@ begin
|
||||
begin
|
||||
WSSetText(AValue);
|
||||
InvalidatePreferredSize;
|
||||
inherited RealSetText(AValue);
|
||||
//don't call inherited (=TControl.)RealSetText(AValue) since it can issue a
|
||||
//second OnChange if RealSetText is called from within OnChange (#0032602)
|
||||
//instead just update FCaption.
|
||||
//WSSetText already makes sure an OnChange will be performed
|
||||
FCaption := AValue;
|
||||
AdjustSize;
|
||||
end
|
||||
else inherited RealSetText(AValue);
|
||||
|
@ -729,7 +729,7 @@ type
|
||||
FOnChange: TNotifyEvent;
|
||||
FSelLength: integer;
|
||||
FSelStart: integer;
|
||||
FTextChangedByRealSetText: Boolean;
|
||||
FTextChangedByRealSetTextCounter: Integer;
|
||||
FTextHint: TTranslateString;
|
||||
procedure ShowEmulatedTextHint(const ForceShow: Boolean = False);
|
||||
procedure HideEmulatedTextHint;
|
||||
|
Loading…
Reference in New Issue
Block a user