The documentation says:
TButtonControl.ClicksDisabled
Disables clicking on the button, without showing the button in a disabled state.
Source position: stdctrls.pp line 1192
protected property TButtonControl.ClicksDisabled : Boolean
read FClicksDisabled
write FClicksDisabled;
Frankly, this "Disables clicking" is as vague as can be, is it user action, programmed action (funciton calls), something yet else? And what specific consequences would it have?
The tone suggests this to be like a published property, to be set in Object Inspector, saved in LFM and be some globally supported flag neutralizing the button, for whatever needs.
Grepping LCL sources, however, brings one single implementer and one single consumer.
procedure TButtonActionLink.SetChecked(Value: Boolean);
begin
if IsCheckedLinked then
begin
FClientButton.ClicksDisabled := True;
try
FClientButton.Checked := Value;
finally
FClientButton.ClicksDisabled := False;
end;
end;
end;
Notice, how the prior value is never checked nor restored, it is just carelessly overwritten.
procedure TCustomCheckBox.DoClickOnChange;
begin
Changed;
// emulate delphi OnClick behaviour (click will call OnChange)
if VCL_OnClick_Emulation and not ClicksDisabled then
inherited Click
else
DoOnChange;
end;
procedure TCustomCheckBox.SetState(Value: TCheckBoxState);
var
OldCheckState: TCheckBoxState;
OldActionListState: TActionListState;
LAction: TBasicAction;
begin
LAction := Action; // property getter is function, call only once.
// TAction does not have the 3rd state, nothing meaningful can be done then
if Value <> cbGrayed then begin
// no infinite recursion when we would be called again later by TAction itself
if not ClicksDisabled then begin
if LAction is TCustomAction then begin
TCustomAction(LAction).Checked := Value = cbChecked;
Exit;
end;
end;
end;
if FState <> Value then
begin
OldCheckState := FState;
FState := Value;
....
...and that is all.
The property is misleadingly named, misleadingly documented, and does not even has to be a property.
So, questions to muse about.
1. Was this property ever used in applications or 3rd party libraries, for sure or at least probably?
2. Can we just remove it and re-implement actions differently? As of now it was broken anyway. The least resistance would be making it a renamed variable inside checklistbox and nowehere else.
3. Should we perhaps uplift it, make published, and make all buttons adhere to it? Or this would be insanity no one needs?
4. Can, maybe, TControlState be extended with a flag, denoting if the curent Click-handling methods were called due to user's action on this very control, or programatically (like TAction, or TDataSet.Next, or radio/speedbuttons cancelling each other)? If so, what should be boundaries? To some extend, csClicked can be used, but i am not sure the boundaries are consistent or documented.
Related:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39869