mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 15:50:25 +02:00
lcl: remove workarounds to recursive LM_CHANGE calls, since it was fixed fixed in rev 27050 #8d7d250608 and 27051:
- don't toggle TRadioButton siblings state since this is done by widgetset; - remove FLastCheckedOnChange; - call OnChange only if State was really changed by widgetset - Dont set Checked property in Click Part of 0017139 and 0017104 git-svn-id: trunk@27053 -
This commit is contained in:
parent
0d8fe57965
commit
1aa796b724
@ -47,19 +47,12 @@ end;
|
|||||||
|
|
||||||
procedure TButtonControl.DoOnChange;
|
procedure TButtonControl.DoOnChange;
|
||||||
begin
|
begin
|
||||||
if Checked = FLastCheckedOnChange then Exit;
|
|
||||||
FLastCheckedOnChange := Checked;
|
|
||||||
if [csLoading, csDestroying, csDesigning] * ComponentState <> [] then Exit;
|
if [csLoading, csDestroying, csDesigning] * ComponentState <> [] then Exit;
|
||||||
EditingDone;
|
EditingDone;
|
||||||
if Assigned(OnChange) then OnChange(Self);
|
if Assigned(OnChange) then OnChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TButtonControl.Loaded;
|
|
||||||
begin
|
|
||||||
inherited Loaded;
|
|
||||||
fLastCheckedOnChange:=Checked;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TButtonControl.CMWantSpecialKey(var Message: TLMessage);
|
procedure TButtonControl.CMWantSpecialKey(var Message: TLMessage);
|
||||||
begin
|
begin
|
||||||
// button controls dont want any special keys
|
// button controls dont want any special keys
|
||||||
|
@ -53,13 +53,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCheckBox.DoChange(var Msg);
|
procedure TCustomCheckBox.DoChange(var Msg);
|
||||||
var
|
|
||||||
NewState: TCheckBoxState;
|
|
||||||
begin
|
begin
|
||||||
NewState := RetrieveState;
|
FState := RetrieveState;
|
||||||
if FState = NewState then exit;
|
|
||||||
FState := NewState;
|
|
||||||
// emulate delphi OnClick behaviour
|
|
||||||
DoClickOnChange;
|
DoClickOnChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -154,8 +149,10 @@ begin
|
|||||||
if Assigned(Action) and (Action is TCustomAction) then
|
if Assigned(Action) and (Action is TCustomAction) then
|
||||||
TCustomAction(Action).Checked := FState = cbChecked;
|
TCustomAction(Action).Checked := FState = cbChecked;
|
||||||
ApplyChanges;
|
ApplyChanges;
|
||||||
DoOnChange;
|
//some widgetsets (gtk*) does not allow to uncheck a radio button
|
||||||
if not ClicksDisabled then
|
//only call OnChange if effectivelly changed
|
||||||
|
FState := RetrieveState;
|
||||||
|
if FState <> OldState then
|
||||||
DoClickOnChange;
|
DoClickOnChange;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -249,7 +246,11 @@ end;
|
|||||||
|
|
||||||
procedure TCustomCheckBox.DoClickOnChange;
|
procedure TCustomCheckBox.DoClickOnChange;
|
||||||
begin
|
begin
|
||||||
inherited Click;
|
// emulate delphi OnClick behaviour (click will call OnChange)
|
||||||
|
if not ClicksDisabled then
|
||||||
|
inherited Click
|
||||||
|
else
|
||||||
|
DoOnChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomCheckBox.DialogChar(var Message: TLMKey): boolean;
|
function TCustomCheckBox.DialogChar(var Message: TLMKey): boolean;
|
||||||
|
@ -71,44 +71,14 @@ begin
|
|||||||
AdjustSize;
|
AdjustSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRadioButton.ApplyChanges;
|
|
||||||
begin
|
|
||||||
inherited ApplyChanges;
|
|
||||||
DoApplyChanges;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TRadioButton.SetChecked(Value: Boolean);
|
|
||||||
begin
|
|
||||||
inherited SetChecked(Value);
|
|
||||||
TabStop := Value;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TRadioButton.DoChange(var Msg);
|
|
||||||
begin
|
|
||||||
inherited DoChange(Msg);
|
|
||||||
DoApplyChanges;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TRadioButton.DoApplyChanges;
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
Sibling: TControl;
|
|
||||||
begin
|
|
||||||
if not (csLoading in ComponentState) and (Parent <> nil) and (FState = cbChecked) then
|
|
||||||
begin
|
|
||||||
for i := 0 to Parent.ControlCount - 1 do
|
|
||||||
begin
|
|
||||||
Sibling := Parent.Controls[i];
|
|
||||||
if (Sibling is TRadioButton) and (Sibling <> Self) then
|
|
||||||
TRadioButton(Sibling).Checked := False;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TRadioButton.DoClickOnChange;
|
procedure TRadioButton.DoClickOnChange;
|
||||||
begin
|
begin
|
||||||
if State = cbChecked then
|
TabStop := FState = cbChecked;
|
||||||
inherited DoClickOnChange;
|
//inherited calls DoOnChange
|
||||||
|
if FState = cbChecked then
|
||||||
|
inherited DoClickOnChange
|
||||||
|
else
|
||||||
|
DoOnChange;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRadioButton.CreateParams(var Params: TCreateParams);
|
procedure TRadioButton.CreateParams(var Params: TCreateParams);
|
||||||
@ -125,12 +95,6 @@ begin
|
|||||||
RegisterRadioButton;
|
RegisterRadioButton;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRadioButton.Click;
|
|
||||||
begin
|
|
||||||
Checked := True;
|
|
||||||
inherited Click;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TRadioButton.DialogChar(var Message: TLMKey): boolean;
|
function TRadioButton.DialogChar(var Message: TLMKey): boolean;
|
||||||
begin
|
begin
|
||||||
if IsAccel(Message.CharCode, Caption) and CanFocus then
|
if IsAccel(Message.CharCode, Caption) and CanFocus then
|
||||||
|
@ -1041,13 +1041,11 @@ type
|
|||||||
function IsCheckedStored: boolean;
|
function IsCheckedStored: boolean;
|
||||||
procedure WMDefaultClicked(var Message: TLMessage); message LM_CLICKED;
|
procedure WMDefaultClicked(var Message: TLMessage); message LM_CLICKED;
|
||||||
protected
|
protected
|
||||||
FLastCheckedOnChange: boolean;
|
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
function GetChecked: Boolean; virtual;
|
function GetChecked: Boolean; virtual;
|
||||||
procedure SetChecked(Value: Boolean); virtual;
|
procedure SetChecked(Value: Boolean); virtual;
|
||||||
procedure DoOnChange; virtual;
|
procedure DoOnChange; virtual;
|
||||||
procedure Click; override;
|
procedure Click; override;
|
||||||
procedure Loaded; override;
|
|
||||||
procedure CMWantSpecialKey(var Message: TLMessage); message CM_WANTSPECIALKEY;
|
procedure CMWantSpecialKey(var Message: TLMessage); message CM_WANTSPECIALKEY;
|
||||||
protected
|
protected
|
||||||
property Checked: Boolean read GetChecked write SetChecked stored IsCheckedStored default False;
|
property Checked: Boolean read GetChecked write SetChecked stored IsCheckedStored default False;
|
||||||
@ -1317,13 +1315,8 @@ type
|
|||||||
TRadioButton = class(TCustomCheckBox)
|
TRadioButton = class(TCustomCheckBox)
|
||||||
protected
|
protected
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
procedure Click; override;
|
|
||||||
function DialogChar(var Message: TLMKey): boolean; override;
|
function DialogChar(var Message: TLMKey): boolean; override;
|
||||||
procedure RealSetText(const Value: TCaption); override;
|
procedure RealSetText(const Value: TCaption); override;
|
||||||
procedure ApplyChanges; override;
|
|
||||||
procedure SetChecked(Value: Boolean); override;
|
|
||||||
procedure DoChange(var Msg); message LM_CHANGED;
|
|
||||||
procedure DoApplyChanges;
|
|
||||||
procedure DoClickOnChange; override;
|
procedure DoClickOnChange; override;
|
||||||
procedure CreateParams(var Params: TCreateParams); override;
|
procedure CreateParams(var Params: TCreateParams); override;
|
||||||
public
|
public
|
||||||
|
Loading…
Reference in New Issue
Block a user