B4J Question Detect Event In GroupRadioButtons

oldeast

Active Member
Licensed User
Longtime User
I have grouped radio buttons in a pane, selecting one deselects the others.
Each of the rbos has a unique tag, the currently selected rbo tag value is stored in a variable.
How do I detect the change in one of the rbos so I can update the stored value.
Thanks.
Graham
B4X:
Dim n As Node
    For Each n As Node In paneHist.GetAllViewsRecursive
        If n Is RadioButton Then LHis.Add(n)
    Next
            Hist1.GroupRadioButtons(LHis)
            Hist2.GroupRadioButtons(LHis)
            Hist3.GroupRadioButtons(LHis)
            Hist4.GroupRadioButtons(LHis)
            Hist5.GroupRadioButtons(LHis)
 

eurojam

Well-Known Member
Licensed User
Longtime User
you have to give them all the same eventName and then you get your radiobutton with the sender keyword:
B4X:
Sub RadioButton_SelectedChange(Selected As Boolean)
  dim rb as radiobutton   
  rb = sender
  Log(rb)
End Sub
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Small enhancement to get the selected RadioButton:

B4X:
Sub RadioButton_SelectedChange(Selected As Boolean)
  Dim rb as RadioButton
  rb = sender
  If rb.Selected Then Log(rb.Text) 
End Sub
 
Upvote 0

oldeast

Active Member
Licensed User
Longtime User
Thanks, I have used a single event name HistClcik.

I tried this ..
B4X:
Sub HistClick_SelectedChange(Checked As Boolean)
    Dim rbo As RadioButton
    If Checked=True Then
        rbo=Sender
        Log(rbo)
        txtHist.text=rbo.Tag
        ObjectForm.Aes=txtAes.text
        txtCultValue.text=Utils.GetCval   
End If

and it works, thanks very much.
Graham
 
Upvote 0
Top