mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 04:49:40 +02:00
lcl: use correct method to restore Default and Cancel of TCustomButton (Loaded instead of SetParent), remove TButtonPanel.RestoreCancel workaround
git-svn-id: trunk@18460 -
This commit is contained in:
parent
e3f461ec5f
commit
5980abdcec
@ -61,7 +61,6 @@ type
|
||||
FSpacing: TSpacingSize;
|
||||
procedure CreateButton(AButton: TPanelButton);
|
||||
procedure DoDefaultButton;
|
||||
procedure DoRestoreCancel;
|
||||
procedure DoShowButtons;
|
||||
procedure DoShowGlyphs;
|
||||
procedure SetButtonOrder(Value: TButtonOrder);
|
||||
@ -317,15 +316,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonPanel.DoRestoreCancel;
|
||||
begin
|
||||
if FButtons[pbCancel] = nil then Exit;
|
||||
|
||||
// to restore cancel button we need to do this hack
|
||||
FButtons[pbCancel].Cancel := False;
|
||||
FButtons[pbCancel].Cancel := True;
|
||||
end;
|
||||
|
||||
procedure TCustomButtonPanel.SetDefaultButton(Value: TPanelButton);
|
||||
begin
|
||||
if FDefaultButton = Value then
|
||||
@ -359,7 +349,6 @@ procedure TCustomButtonPanel.Loaded;
|
||||
begin
|
||||
inherited Loaded;
|
||||
|
||||
DoRestoreCancel;
|
||||
Realign;
|
||||
end;
|
||||
|
||||
|
@ -58,32 +58,11 @@ begin
|
||||
inherited ControlKeyDown(Key, Shift);
|
||||
end;
|
||||
|
||||
procedure TCustomButton.ControlKeyUp(var Key: Word; Shift: TShiftState
|
||||
);
|
||||
procedure TCustomButton.ControlKeyUp(var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
inherited ControlKeyUp(Key, Shift);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomButton.SetParent(AParent: TWinControl);
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomButton.SetParent(AParent: TWinControl);
|
||||
var
|
||||
Form: TCustomForm;
|
||||
begin
|
||||
if Parent=AParent then exit;
|
||||
inherited SetParent(AParent);
|
||||
Form := GetParentForm(Self);
|
||||
if Form <> nil then
|
||||
begin
|
||||
if FDefault then
|
||||
Form.DefaultControl := Self;
|
||||
if FCancel then
|
||||
Form.CancelControl := Self;
|
||||
end;
|
||||
WSSetDefault;
|
||||
end;
|
||||
|
||||
procedure TCustomButton.UpdateRolesForForm;
|
||||
var
|
||||
AForm: TCustomForm;
|
||||
@ -304,6 +283,23 @@ begin
|
||||
inherited TextChanged;
|
||||
end;
|
||||
|
||||
procedure TCustomButton.Loaded;
|
||||
var
|
||||
Form: TCustomForm;
|
||||
begin
|
||||
inherited Loaded;
|
||||
|
||||
Form := GetParentForm(Self);
|
||||
if Form <> nil then
|
||||
begin
|
||||
if FDefault then
|
||||
Form.DefaultControl := Self;
|
||||
if FCancel then
|
||||
Form.CancelControl := Self;
|
||||
end;
|
||||
WSSetDefault;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomButton.DoSendBtnDefault;
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -3144,7 +3144,7 @@ end;
|
||||
TControl SetParentComponent
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.SetParentComponent(NewParentComponent: TComponent);
|
||||
Begin
|
||||
begin
|
||||
if (NewParentComponent is TWinControl) then
|
||||
SetParent(TWinControl(NewParentComponent));
|
||||
end;
|
||||
|
@ -1060,7 +1060,6 @@ type
|
||||
procedure CreateWnd; override;
|
||||
procedure ControlKeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure ControlKeyUp(var Key: Word; Shift: TShiftState); override;
|
||||
procedure SetParent(AParent: TWinControl); override;
|
||||
function DialogChar(var Message: TLMKey): boolean; override;
|
||||
function ChildClassAllowed(ChildClass: TClass): boolean; override;
|
||||
class function GetControlClassDefaultSize: TPoint; override;
|
||||
@ -1068,6 +1067,7 @@ type
|
||||
procedure WSSetDefault;
|
||||
procedure WSSetText(const AText: String); override;
|
||||
procedure TextChanged; override;
|
||||
procedure Loaded; override;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
procedure ExecuteDefaultAction; override;
|
||||
|
Loading…
Reference in New Issue
Block a user