request for advice on coding of radio buttons
Jun 19, 2018 20:38:43 GMT 1
Post by ptitjoz on Jun 19, 2018 20:38:43 GMT 1
Hello
I tested this little code by searching a little in the documentation and on the forum.
I tested this little code by searching a little in the documentation and on the forum.
Can we do more simple or more optimized?
Thank you for your advice
Regards
Joz
INCLUDE "./../Lib/hug.bac"
'----------------------------------------------------------------------
SUB SubClean
TEXT(Edit1,"")
END SUB
SUB RadioGroup1(NUMBER widget)
SELECT widget
CASE Radio1
IF GET(widget) THEN TEXT(Edit1,GRAB$(widget)&NL$)
CASE Radio2
IF GET(widget) THEN TEXT(Edit1,GRAB$(widget)&NL$)
END SELECT
END SUB
SUB RadioGroup2(NUMBER widget)
SELECT widget
CASE Radio3
IF GET(widget) THEN TEXT(Edit1,GRAB$(widget)&NL$)
CASE Radio4
IF GET(widget) THEN TEXT(Edit1,GRAB$(widget)&NL$)
CASE Radio5
IF GET(widget) THEN TEXT(Edit1,GRAB$(widget)&NL$)
END SELECT
END SUB
'----------------------------------------------------------------------
Form1 = WINDOW( "BaCon bouttons-radios et groupes", 400, 300 )
'----------------------------------------------------------------------
Frame1=FRAME(160,80)
SETPROPERTY(Frame1,"tooltip-text","choix dans groupe 1")
ATTACH(Form1,Frame1,10,10)
Label1=MARK("Groupe 1",150,30)
ATTACH(Form1,Label1,10,10)
' Création des boutons radio du RadioGroup1 se rattachant au boutton 1
' le premier bouton radio a toujours le numéro 0 (3ème argurment)
' les autres, du groupe, ont le nom du premier boutton (3ème argument ici RadioGroup1)
Radio1 = RADIO("Boutton Radio 1",150,25,0)
ATTACH( Form1, Radio1,20,40 )
CALLBACK(Radio1, RadioGroup1)
Radio2 = RADIO("Boutton Radio 2", 150, 25,Radio1)
ATTACH(Form1, Radio2, 20, 60)
CALLBACK(Radio2, RadioGroup1)
'----------------------------------------------------------------------
Frame2=FRAME(160,100)
SETPROPERTY(Frame2,"tooltip-text","choix dans groupe 2")
ATTACH(Form1,Frame2,10,110)
Label2=MARK("Groupe 2",150,30)
ATTACH(Form1,Label2,10,110)
Radio3 = RADIO("Boutton Radio 3",150,25,0)
ATTACH( Form1, Radio3,20,140 )
CALLBACK(Radio3, RadioGroup2)
Radio4 = RADIO("Boutton Radio 4",150,25,Radio3)
ATTACH(Form1, Radio4,20,160)
CALLBACK(Radio4, RadioGroup2)
Radio5 = RADIO("Boutton Radio 5", 150, 25,Radio3)
ATTACH(Form1, Radio5,20,180)
CALLBACK(Radio5, RadioGroup2)
'----------------------------------------------------------------------
Button1=STOCK("gtk-quit", 80, 25)
ATTACH(Form1, Button1, 150, 250)
CALLBACK(Button1,QUIT)
Button2=BUTTON("Effacer",80,25)
ATTACH(Form1, Button2,20,250)
CALLBACK(Button2,SubClean)
'----------------------------------------------------------------------
Edit1=EDIT(160,220)
ATTACH(Form1,Edit1,200,10)
'----------------------------------------------------------------------
DISPLAY