Dialog OptionGadget

Just starting out? Need help? Post your questions and find answers here.
wombats
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Dec 29, 2011 5:03 pm

Dialog OptionGadget

Post by wombats »

I'm not entirely sure that this isn't the intended behaviour (I can't really see how it would be), but when you have OptionGadgets with different groups in the same layout element, the 'group' tag is ignored.

gridbox:

Code: Select all

Runtime Enumeration
  #Dialog
  #Gadget1
  #Gadget2
  #Gadget3
  #Gadget4
  #XML 
EndEnumeration

xml$ = "<window id='#PB_Any' name='test' text='test' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"
xml$ + "  <gridbox columns='2'>"
xml$ + "    <option id='#Gadget1' text='One' width='90' group='one'/>"
xml$ + "    <option id='#Gadget2' text='Two' width='90' group='one'/>"
xml$ + "    <option id='#Gadget3' text='One' width='90' group='two'/>"
xml$ + "    <option id='#Gadget4' text='Two' width='90' group='two'/>"
xml$ + "  </gridbox>"
xml$ + "</window>"

If ParseXML(#XML, XML$) And XMLStatus(#XML) = #PB_XML_Success
  
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #XML, "test")
    
    SetGadgetState(#Gadget3, 1)
    SetGadgetState(#Gadget1, 1)

    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow 
    
  Else  
    Debug "Dialog error: " + DialogError(#Dialog)
  EndIf
Else
  Debug "XML error: " + XMLError(#XML) + " (Line: " + XMLErrorLine(#XML) + ")"
EndIf
hbox:

Code: Select all

Runtime Enumeration
  #Dialog
  #Gadget1
  #Gadget2
  #Gadget3
  #Gadget4
  #XML 
EndEnumeration

xml$ = "<window id='#PB_Any' name='test' text='test' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"
xml$ + "  <hbox>"
xml$ + "    <option id='#Gadget1' text='One' width='90' group='one'/>"
xml$ + "    <option id='#Gadget2' text='Two' width='90' group='one'/>"
xml$ + "    <option id='#Gadget3' text='One' width='90' group='two'/>"
xml$ + "    <option id='#Gadget4' text='Two' width='90' group='two'/>"
xml$ + "  </hbox>"
xml$ + "</window>"

If ParseXML(#XML, XML$) And XMLStatus(#XML) = #PB_XML_Success
  
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #XML, "test")
    
    SetGadgetState(#Gadget3, 1)
    SetGadgetState(#Gadget1, 1)

    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow 
    
  Else  
    Debug "Dialog error: " + DialogError(#Dialog)
  EndIf
Else
  Debug "XML error: " + XMLError(#XML) + " (Line: " + XMLErrorLine(#XML) + ")"
EndIf
User avatar
HeX0R
Addict
Addict
Posts: 992
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Dialog OptionGadget

Post by HeX0R »

The group tag works only with numbers correctly.
I'm not sure if this is by design or not, but I also needed quite a while to find that out, maybe the help file should be updated at least to make that clear.

Code: Select all

Runtime Enumeration
  #Dialog
  #Gadget1
  #Gadget2
  #Gadget3
  #Gadget4
  #XML
EndEnumeration

xml$ = "<window id='#PB_Any' name='test' text='test' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"
xml$ + "  <gridbox columns='2'>"
xml$ + "    <option id='#Gadget1' text='One' width='90' group='1'/>"
xml$ + "    <option id='#Gadget2' text='Two' width='90' group='1'/>"
xml$ + "    <option id='#Gadget3' text='One' width='90' group='2'/>"
xml$ + "    <option id='#Gadget4' text='Two' width='90' group='2'/>"
xml$ + "  </gridbox>"
xml$ + "</window>"

If ParseXML(#XML, XML$) And XMLStatus(#XML) = #PB_XML_Success
 
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #XML, "test")
   
    SetGadgetState(#Gadget3, 1)
    SetGadgetState(#Gadget1, 1)

    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
   
  Else 
    Debug "Dialog error: " + DialogError(#Dialog)
  EndIf
Else
  Debug "XML error: " + XMLError(#XML) + " (Line: " + XMLErrorLine(#XML) + ")"
EndIf
wombats
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Dec 29, 2011 5:03 pm

Re: Dialog OptionGadget

Post by wombats »

:oops: Thanks for pointing that out. I completely skipped over where it says "number" in the help. I guess this isn't a bug.
Post Reply