Radio Buttons or Option Buttons in Dialogs

Hi All,

In my attempt to learn a little macro programming in LibreOffice I created some Form Controls that included some Option Buttons.

In order to determine which Option Button was selected there was a method to get all of the Option Buttons in a group as below.

oForm.getGroupByName("GroupName", Array)

I later tried to use a Dialog in place of the form and found that the above method for getting the Option Buttons in the Dialog did not work.

After searching for a solution on the internet and coming up empty I came up with the following as my solution which seems to work.
If there is a better way or right way, please let me know.

You can then loop iterate the array and look at each controls State to determine which option is selected.
I use the control name by getting control.Model.Name

Thanks

Dim arr(0) as Object
Dim groupName as String
groupName = "YourGroupName"
arrRadioBtns = getRadioGroupByName(inDialog, groupName, arr) 

Function getRadioGroupByName(inDialog, inGroup, inArray) as Array
Rem inArray should be an array with 1 element arr(0). Its going to get redimentioned later.
Dim oDialogControls as Object
oDialogControls = inDialog.Controls
For Each control in oDialogControls
	If inStr(control.Model.DefaultControl, "RadioButton") <> 0 Then
		If strComp(control.Model.GroupName, inGroup) = 0 Then
			ReDim Preserve inArray(idx)
			inArray(idx) = control
			idx = idx + 1
		
		End If
	End If

next
getRadioGroupByName = inArray	
End Function

Please upload your .ods type sample file here.

Uploading my sample document. Hopefully someone can find something useful in the macros. Everything in the macros is information i was able to find researching the internet.

blank check register dialog Test.ods (16.4 KB)