Result = OptionGadget(#Gadget, x, y, Width, Height, Text$)
The first time this function is called, a group is created and all following calls of OptionGadget() will add a gadget to this group. To finish the group, just create a gadget of another type. These kind of gadgets are very useful as only one gadget from the group can be selected at any time.
It work difference in Windows and Linux. In Windows I can select more radio buttons in a group. In linux not. How can I select more radio buttons in Linux. I don't no how to start a new group ? Just create a gardget of another type. Have you a example, I don't understand this !
Thanks,
Stephan
How to select many radio buttons ?
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: How to select many radio buttons ?
Crude example:
Code: Select all
Enumeration
#WinMain
#OptA1
#OptA2
#OptA3
#OptA4
#HiddenTxt
#OptB1
#OptB2
#OptB3
#OptB4
#BtnOK
EndEnumeration
Procedure OpenWin()
;------------------
If OpenWindow(#WinMain, 0, 0, 300, 200, "Radio buttons", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
OptionGadget(#OptA1, 10, 10, 100, 25, "Option A 1")
OptionGadget(#OptA2, 10, 35, 100, 25, "Option A 2")
OptionGadget(#OptA3, 10, 60, 100, 25, "Option A 3")
OptionGadget(#OptA4, 10, 85, 100, 25, "Option A 4")
TextGadget(#HiddenTxt, 10, 150, 10, 10, "")
OptionGadget(#OptB1, 200, 10, 100, 25, "Option B 1")
OptionGadget(#OptB2, 200, 35, 100, 25, "Option B 2")
OptionGadget(#OptB3, 200, 60, 100, 25, "Option B 3")
OptionGadget(#OptB4, 200, 85, 100, 25, "Option B 4")
ButtonGadget(#BtnOK, 100, 150, 100, 30, "OK")
EndIf
EndProcedure
Procedure WaitForUser()
;---------------------
Protected iEvent.i = 0
Protected iGdgID.i = 0
Repeat
iEvent = WaitWindowEvent(1)
Select iEvent
Case #PB_Event_Gadget
iGdgID = EventGadget()
Select iGdgID
Case #BtnOK : iEvent = #PB_Event_CloseWindow
EndSelect
EndSelect
Until iEvent = #PB_Event_CloseWindow
EndProcedure
OpenWin()
WaitForUser()
CloseWindow(#WinMain)
EndIdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: How to select many radio buttons ?
Here's another way, basically the same, but using a convenient little Macro.
Code: Select all
; Finishes a sequence of OptionGadgets by creating and immediately deleting a temporary TextGadget
Macro FinishOptionGadgets()
FreeGadget(TextGadget(#PB_Any, 0, 0, 0, 0, ""))
EndMacro
OpenWindow(0, 0, 0, 320, 240, "Option Gadget Groups", #PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
; Create group 1
For n = 0 To 2
OptionGadget(n, 10, 10 + n*20, 200, 20, "Hello " + Str(n+1))
Next n
SetGadgetState(0, #True)
; Finish group 1
FinishOptionGadgets()
; Create group 2
For n = 0 To 2
OptionGadget(n + 3, 10, 75 + n*20, 200, 20, "World " + Str(n+1))
Next n
SetGadgetState(3, #True)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
