Class XbpRadioButton() Foundation

Class function of the XbpRadioButton class.


The XbpRadioButton class provides the radio button dialog element. A radiobutton, like a checkbox, can be in one of two available states: "selected" or "not selected". These two conditions are identified by the logical values .T. (true) and .F. (false).

A radiobutton differs from a checkbox in that it must always be part of a group of two or more radiobuttons. Within each group of radiobuttons only a single radiobutton can be selected at any one time. The relationship of a radiobutton to the group is defined by the parent and owner of the radiobuttons. All radiobuttons that have the same parent and owner belong to a single radiobutton group. If a radiobutton that was not previously selected is clicked, it changes to the "selected" state and the previously selected radiobutton is reset to the "not selected" state. The XbpStatic dialog element is generally used to draw a box around the radiobuttons and is used as the parent and owner for the radiobutton group. This allows the radiobuttons to be visually grouped and multiple radiobutton groups to be placed in a single window.

Class methods
Creates an instance of the XbpRadioButton class.

The instance variables in this group configure system resources. If changes are made to these values, they must either be made before the :create() method is executed or the :configure() method must be used to activate the changes.

Automatically fits the size of the radiobutton to the caption.
The caption of the radiobutton.
Indicates whether the radiobutton receives input focus when the mouse is clicked on it.
The state of the XbpRadioButton object.
Life cycle
Requests system resources for the XbpRadioButton object.
Reconfigures the XbpRadioButton object after :create() has been executed.
Releases the system resources of the XbpRadioButton object.
Returns the value in the edit buffer of the radiobutton.
Returns the current state of the radiobutton.
Specifies a new caption.
Sets the current value or state of the radiobutton.
Radiobutton has been selected.
Selection using radiobuttons

// The example demonstrates the basic process 
// for creating radiobuttons. An XbpStatic 
// object is used as the parent (this is also 
// the owner by default) to combine the four 
// radiobuttons into one group. 

#include "" 
#include "" 

   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL oStatic, oRadio, bSelected 

   SetColor( "N/W" ) 

   // XbpStatic to act as parent and owner of the radiobuttons 
   oStatic         := XbpStatic():new( ,, {200,120}, {120,150} ) 
   oStatic:type    := XBPSTATIC_TYPE_GROUPBOX 
   oStatic:caption := "COM Ports" 

   // Display which radiobutton is selected 
   bSelected := {|mp1,mp2,obj| QOut( obj:caption ) } 

   // Create four radiobuttons 
   // ( Owner == Parent == oStatic ) 
   oRadio := XbpRadioButton():new( oStatic,, {20,100}, {80,20} ) 
   oRadio:caption   := "COM 1" 
   oRadio:selection :=.T. 
   oRadio:selected  := bSelected 

   oRadio := XbpRadioButton():new( oStatic,, {20,70}, {80,20} ) 
   oRadio:caption   := "COM 2" 
   oRadio:selected  := bSelected 

   oRadio := XbpRadioButton():new( oStatic,, {20,40}, {80,20} ) 
   oRadio:caption   := "COM 3" 
   oRadio:selected  := bSelected 

   oRadio := XbpRadioButton():new( oStatic,, {20,10}, {80,20} ) 
   oRadio:caption   := "COM 4" 
   oRadio:selected  := bSelected 

   nEvent := 0 
   DO WHILE nEvent <> xbeP_Close 
      nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
      oXbp:handleEvent( nEvent, mp1, mp2 ) 

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.