From f91a0b7b97a8a37b876b827b72c66ca1116dcce4 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 9 Feb 2005 11:25:19 +0000 Subject: [PATCH] fixed loading TSpeedButton.Down from Yoyong git-svn-id: trunk@6775 - --- ide/customformeditor.pp | 9 ++++---- lcl/buttons.pp | 5 +++++ lcl/include/speedbutton.inc | 42 ++++++++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/ide/customformeditor.pp b/ide/customformeditor.pp index 11dcd8bc3e..6053ad951a 100644 --- a/ide/customformeditor.pp +++ b/ide/customformeditor.pp @@ -1215,6 +1215,8 @@ Var Begin Result:=nil; Temp:=nil; + ParentComponent:=nil; + AParent:=nil; try DebugLn('[TCustomFormEditor.CreateComponent] Class='''+TypeClass.ClassName+''''); {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TCustomFormEditor.CreateComponent A');{$ENDIF} @@ -1257,12 +1259,10 @@ Begin end else begin AParent := TControl(ParentComponent).Parent; end; - DebugLn('Parent is '''+AParent.Name+''''); + DebugLn('Parent is '''+dbgsName(AParent)+''''); end else begin // create a toplevel component // -> a form or a datamodule or a custom component - ParentComponent:=nil; - AParent:=nil; JITList:=GetJITListOfType(TypeClass); if JITList=nil then RaiseException('TCustomFormEditor.CreateComponent '+TypeClass.ClassName); @@ -1281,8 +1281,7 @@ Begin on e: Exception do begin MessageDlg('Error naming component', 'Error setting the name of a component ' - +Temp.Component.Name+':'+Temp.Component.ClassName - +' to '+NewComponentName, + +dbgsName(Temp.Component)+' to '+NewComponentName, mtError,[mbCancel],0); exit; end; diff --git a/lcl/buttons.pp b/lcl/buttons.pp index 710861b342..361219a5a6 100644 --- a/lcl/buttons.pp +++ b/lcl/buttons.pp @@ -253,6 +253,7 @@ type private FAllowAllUp: Boolean; FDown: Boolean; + FDownBuffered : Boolean;//buffered value of FDown FDragging: Boolean; FFlat: Boolean; FGlyph: TButtonGlyph; @@ -296,6 +297,7 @@ type property MouseInControl: Boolean read FMouseInControl; procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override; function GetActionLinkClass: TControlActionLinkClass; override; + procedure Loaded; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -387,6 +389,9 @@ end. { ============================================================================= $Log$ + Revision 1.88 2005/02/09 11:25:19 mattias + fixed loading TSpeedButton.Down from Yoyong + Revision 1.87 2005/02/08 21:46:22 vincents fixed fpc 1.0.x compilation diff --git a/lcl/include/speedbutton.inc b/lcl/include/speedbutton.inc index 1d215f090e..77e0ab2e4b 100644 --- a/lcl/include/speedbutton.inc +++ b/lcl/include/speedbutton.inc @@ -102,19 +102,28 @@ var OldState: TButtonState; OldDown: Boolean; begin - if FGroupIndex = 0 then Value:= false; - if FDown <> Value then begin - if FDown and not FAllowAllUp then Exit; - OldDown:=FDown; - FDown := Value; - OldState := fState; - if FDown then begin - fState := bsExclusive; - end else begin - FState := bsUp; + //since Down needs GroupIndex, then we need to wait that all properties + //loaded before we continue + if (csLoading in ComponentState) then begin + FDownBuffered := Value; + exit; + end else begin + if FGroupIndex = 0 then Value:= false; + if FDown <> Value then begin + if FDown and not FAllowAllUp then Exit; + OldDown:=FDown; + FDown := Value; + OldState := fState; + if FDown then begin + fState := bsExclusive; + end else begin + FState := bsUp; + end; + if (OldDown<>FDown) or (OldState<>FState) then Invalidate; + if Value then begin + UpdateExclusive; + end; end; - if (OldDown<>FDown) or (OldState<>FState) then Invalidate; - if Value then UpdateExclusive; end; end; @@ -668,6 +677,12 @@ begin end; end; +procedure TCustomSpeedButton.Loaded; +begin + inherited Loaded; + if FDownBuffered then SetDown(FDownBuffered); +end; + {------------------------------------------------------------------------------ Method: TCustomSpeedButton.CMEnabledChanged @@ -769,6 +784,9 @@ end; { ============================================================================= $Log$ + Revision 1.64 2005/02/09 11:25:19 mattias + fixed loading TSpeedButton.Down from Yoyong + Revision 1.63 2005/02/05 16:09:52 marc * first 64bit changes