Hello All,
I want to use a group o 3 togglebuttons to use in group
(if one is selected the others are automatically unselected).
I tried to do by myself but I'm having some issue.
Particularly because the change of the toggle is happening before the execution of my code (I suppose)
I've found other post with related topic but no solution/code.
Below my solution.
Any comment/clue is useful.
I've 3 buttons in the Designer
and I'm managing in group sharing the event and checking the sender.
I'm using tags to manage the status
Also there is a variable (selected_metric) to keep current selected (maybe this could be not necessary)
This code seems to work but sometime fails above all when tapping on already active button
:-(
TIA
in the meantime I'm continuing to work on it
dex
I want to use a group o 3 togglebuttons to use in group
(if one is selected the others are automatically unselected).
I tried to do by myself but I'm having some issue.
Particularly because the change of the toggle is happening before the execution of my code (I suppose)
I've found other post with related topic but no solution/code.
Below my solution.
Any comment/clue is useful.
I've 3 buttons in the Designer
and I'm managing in group sharing the event and checking the sender.
I'm using tags to manage the status
Also there is a variable (selected_metric) to keep current selected (maybe this could be not necessary)
This code seems to work but sometime fails above all when tapping on already active button
:-(
TIA
in the meantime I'm continuing to work on it
dex
B4X:
Sub btn_g1_CheckedChange(Checked As Boolean)
Dim s As String
Dim b As ToggleButton
b = Sender
s = b.Tag & ":" & b.Checked & selected_metric
Log (s)
If selected_metric = b.Tag Then
b.Checked = True
Else
Select b.Tag
Case "time"
btn_time.Checked = True
btn_bpm.Checked = False
btn_hz.Checked = False
Case "bpm"
btn_time.Checked = False
btn_bpm.Checked = True
btn_hz.Checked = False
Case "hz"
btn_time.Checked = False
btn_bpm.Checked = False
btn_hz.Checked = True
End Select
End If
selected_metric = b.Tag
End Sub