LCL: Allow access to buttons in CheckGroup and RadioGroup. Issue #40738, patch by Dean Mustakinov.

This commit is contained in:
Juha 2024-01-30 12:00:03 +02:00
parent 1dbfb8fee2
commit f2a32ca78e
3 changed files with 21 additions and 0 deletions

View File

@ -734,6 +734,7 @@ type
FUpdatingItems: Boolean;
procedure Changed(Sender: TObject);
procedure Clicked(Sender: TObject);
function GetButton(Index: integer): TRadioButton;
procedure ItemEnter(Sender: TObject);
procedure ItemExit(Sender: TObject);
procedure ItemKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
@ -769,6 +770,7 @@ type
function Rows: integer;
public
property AutoFill: Boolean read FAutoFill write SetAutoFill;
property Buttons[Index: integer]: TRadioButton read GetButton;
property ItemIndex: integer read GetItemIndex write SetItemIndex default -1;
property Items: TStrings read FItems write SetItems;
property Columns: integer read FColumns write SetColumns default 1;
@ -859,6 +861,7 @@ type
FColumns: integer;
FOnItemClick: TCheckGroupClicked;
FUpdatingItems: Boolean;
function GetButton(Index: integer): TCheckBox;
function GetChecked(Index: integer): boolean;
function GetCheckEnabled(Index: integer): boolean;
procedure Clicked(Sender: TObject);
@ -895,6 +898,7 @@ type
function Rows: integer;
public
property AutoFill: boolean read FAutoFill write SetAutoFill;
property Buttons[Index: integer]: TCheckBox read GetButton;
property Items: TStrings read FItems write SetItems;
property Checked[Index: integer]: boolean read GetChecked write SetChecked;
property CheckEnabled[Index: integer]: boolean read GetCheckEnabled write SetCheckEnabled;

View File

@ -318,6 +318,11 @@ begin
Result:=TCheckBox(FButtonList[Index]).Checked;
end;
function TCustomCheckGroup.GetButton(Index: integer): TCheckBox;
begin
result := TCheckBox(FButtonList[Index]);
end;
procedure TCustomCheckGroup.SetChecked(Index: integer; const AValue: boolean);
begin
if (Index < -1) or (Index >= FItems.Count) then

View File

@ -520,6 +520,18 @@ Begin
CheckItemIndexChanged;
end;
{------------------------------------------------------------------------------
Method: TCustomRadioGroup.GetButton
Params: Index - index of radio button in a group
Return instance of radio button in a group
------------------------------------------------------------------------------}
function TCustomRadioGroup.GetButton(Index: integer): TRadioButton;
begin
result := TRadioButton(FButtonList[Index]);
end;
{------------------------------------------------------------------------------
Method: TCustomRadioGroup.Changed
Params: sender - the calling object