Page 1 of 1

Autonomous OptionGadgets

Posted: Wed Sep 15, 2004 8:32 pm
by RichardL
I use the following to create an array of 16 Option Gadgets.

Code: Select all

  
For y.w = 0 To 3
    xw.w  = px.w+10
    For x.w = 0 To 3
      OptionGadget(id.w, xw.w,yw.w, 115, 15, "") 
      SetGadgetFont(id.w,cFont.l)
      ; Set colour here... HOW?
      xw.w+120
      id.w+1
      Debug id.w
    Next 
    yw.w+20
  Next 
Later I fill in the text for each button (a serial number) so the user can switch a graphical plot on or off.

My problem is that because I create all the Option Gadgets in one operation they become a group, with exclusive properties. The good book says I can stop this by creating other gadgets in between each option gadget. Apart from being very untidy, I only have a few other gadgets so this is not practical

Question: How can I break the grouping effect ?

Posted: Wed Sep 15, 2004 9:05 pm
by RichardL
OK... I changed the policy and used a Checkbox Gadget which avoids the problem. Now all I have to do is edit the manual to suit! :D

Posted: Wed Sep 15, 2004 9:42 pm
by GedB
ContainerGadgets are the best things for grouping OptionGadgets.

They can also group them visually, which is nice.

The good book really could do with an update to mention this.

btw. You only need to state the type the first time you use the variable. You don't need to type the .w every time.

Code: Select all

If OpenWindow(0, 0, 0, 500, 80, #PB_Window_WindowCentered | #PB_Window_SystemMenu, "Options")
  If CreateGadgetList(WindowID())
    For y.w = 0 To 3
      xw.w = px.w+10
      ContainerGadget(#PB_Any, xw.w, yw.w, 480, 20,  #PB_Container_Single)
      For x.w = 0 To 3
        OptionGadget(id.w, xw.w,0, 115, 15, Str(id))
        SetGadgetFont(id.w,cFont.l)
        ; Set colour here... HOW?
        xw.w+120
        id.w+1
        Debug id.w
      Next
      CloseGadgetList()
      yw.w+20
    Next 
  EndIf
EndIf

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Autonomous OptionGadgets

Posted: Wed Sep 15, 2004 9:59 pm
by PB
> because I create all the Option Gadgets in one operation they become a
> group, with exclusive properties

That's the entire point of OptionGadgets. :) Only one of them, in a group, can
be selected at any time. CheckBoxes, as you discovered, are what you use for
selecting multiple items.