Explorar el Código

TLabel.SetName set Caption

mattias hace 2 años
padre
commit
ca6bb9ef7e
Se han modificado 1 ficheros con 14 adiciones y 0 borrados
  1. 14 0
      src/fresnel.controls.pas

+ 14 - 0
src/fresnel.controls.pas

@@ -72,6 +72,7 @@ type
     FSize: TFresnelPoint; // width+height of Caption
     procedure ComputeMinCaption; virtual;
     procedure SetCaption(const AValue: String); virtual;
+    procedure SetName(const NewName: TComponentName); override;
   public
     function GetMinWidthIntrinsicContentBox: TFresnelLength; override;
     function GetPreferredContentBox_MaxWidth(MaxWidth: TFresnelLength): TFresnelPoint;
@@ -335,6 +336,19 @@ begin
   DomChanged;
 end;
 
+procedure TCustomLabel.SetName(const NewName: TComponentName);
+var
+  ChangeCaption: Boolean;
+begin
+  if Name=NewName then exit;
+  ChangeCaption :=
+    not (csLoading in ComponentState)
+    and (Name = Caption)
+    and ((Owner = nil) or not (csLoading in Owner.ComponentState));
+  inherited SetName(NewName);
+  if ChangeCaption then Caption := NewName;
+end;
+
 function TCustomLabel.GetMinWidthIntrinsicContentBox: TFresnelLength;
 var
   p: TFresnelPoint;