BBjRadioButton::getRadioGroup

Description

In BBj 5.0 and higher, this method returns the BBjRadioGroup with which this BBjRadioButton associated.

Syntax

Return Value

Method

BBjRadioGroup

getRadioGroup()

Parameters

None.

Return Value

Returns the BBjRadioGroup with which this BBjRadioButton is associated.

Remarks

If this radio button is not associated with a BBjRadioGroup, this method returns null().

Example

rem 'get radio group that a radio button is associated with.

rem 'Obtain the instance of the BBjAPI object
let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI) "X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Set addWindow param values
X = 10
Y = 10
WIDTH = 200
HEIGHT = 200
TITLE$="BBj Window"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$)

rem 'Add the radio buttons on the window
myRadioButton1! = myWindow!.addRadioButton(101,10,50,80,30,"Button &1",$0000$)
myRadioButton2! = myWindow!.addRadioButton(102,10,100,80,30,"Button &2",$0000$)
myRadioButton3! = myWindow!.addRadioButton(103,10,150,80,30,"Button &3",$0000$)
myRadioButtonA! = myWindow!.addRadioButton(201,100,50,80,30,"Button &A",$0000$)
myRadioButtonB! = myWindow!.addRadioButton(202,100,100,80,30,"Button &B",$0000$)
myRadioButtonC! = myWindow!.addRadioButton(203,100,150,80,30,"Button &C",$0004$)

rem 'First method
let myVector! = myAPI!.makeVector()

rem 'add the buttons to the vector
myVector!.addItem(myRadioButton1!)
myVector!.addItem(myRadioButton2!)
myVector!.addItem(myRadioButton3!)

rem 'add the grouping
myRadioGroup1! = myWindow!.addRadioGroup(myVector!)

rem 'Second method
myRadioGroup2! = myWindow!.addRadioGroup()
myRadioGroup2!.add(myRadioButtonA!)
myRadioGroup2!.add(myRadioButtonB!)
myRadioGroup2!.add(myRadioButtonC!)

rem 'Demonstrate the use of BBjRadioButton::getRadioGroup
Group! = myRadioButton1!.getRadioGroup()
if (Group! = null()) then
    print "Radio button 1 is not in a group"
else
    Selected! = Group!.getSelected()
    if (Selected! = null()) then
        print "No button is selected in the first group"
    else
        print Selected!.getText()," is selected in the first group"
    endif
endif

Group! = myRadioButtonA!.getRadioGroup()
if (Group! = null()) then
    print "Radio button A is not in a group"
else
    Selected! = Group!.getSelected()
    if (Selected! = null()) then
        print "No button is selected in the second group"
    else
        print Selected!.getText()," is selected in the second group"
    endif
endif

rem 'Register the CALLBACK routines
CALLBACK(ON_CHECK_ON,RADIO_BUTTON_CHECKED,mySysGui!.getContext(),myRadioButton1!.getID())
CALLBACK(ON_CHECK_ON,RADIO_BUTTON_CHECKED,mySysGui!.getContext(),myRadioButton2!.getID())
CALLBACK(ON_CHECK_ON,RADIO_BUTTON_CHECKED,mySysGui!.getContext(),myRadioButton3!.getID())
CALLBACK(ON_CHECK_ON,RADIO_BUTTON_CHECKED,mySysGui!.getContext(),myRadioButtonA!.getID())
CALLBACK(ON_CHECK_ON,RADIO_BUTTON_CHECKED,mySysGui!.getContext(),myRadioButtonB!.getID())
CALLBACK(ON_CHECK_ON,RADIO_BUTTON_CHECKED,mySysGui!.getContext(),myRadioButtonC!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

rem 'Process Events
process_events

rem 'Callback routine called when the radio button is checked
RADIO_BUTTON_CHECKED:
    rem 'Display a message that the radio button is checked
    MESSAGE$="Checked "+mySysGui!.getLastEvent().getControl().getText()
    let X = MSGBOX(MESSAGE$)
return

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.