Autonomous OptionGadgets

Windows specific forum
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Autonomous OptionGadgets

Post 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 ?
RichardL
Enthusiast
Enthusiast
Posts: 532
Joined: Sat Sep 11, 2004 11:54 am
Location: UK

Post 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
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post 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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Autonomous OptionGadgets

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply