BBjRadioGroup::setCallback

Description

In BBj 23.00 and higher, this method registers the callback routine for a specified event of the BBjRadioGroup.

Syntax

Return Value

Method

void

setCallback(int eventType, string subRoutineName)

void

setCallback(int eventType, CustomObject customObj, string methodName)

Parameters

Variable

Description

eventType

Event type for which the callback is to be registered.

subRoutineName

Subroutine name to be executed in PROCESS_EVENTS.

customObj

A CustomObject containing the method to be called when the event is processed by PROCESS_EVENTS.

methodName

The name of the method that is to be called when the event is processed by PROCESS_EVENTS.

Return Value

None.

Remarks

A callback can only be registered for event types that a specific control can trigger. The documentation for each control contains a list of events for which callbacks can be registered.

The CALLBACK verb will implicitly GOSUB to the subroutine specified in subroutineName. Since the block of code executed at subroutineName is arrived at via an implicit GOSUB, a RETURN is required at the end of the subroutine.

The CALLBACK implicitly CALLs the publicProgram at the given EntryPoint when the CALLBACK VERB uses the publicProgramEntryPoint syntax (ie: "publicProgram::EntryPoint"). Since a CALL has been made to a public program, an ENTER may optionally be used at the beginning, and an EXIT is required at the end.

The setCallback method must be called before the PROCESS_EVENTS verb, or within a subroutine that is called in response to an event.

If more than one callback is registered for a specific BBjRadioGroup event, the most recent will be used in PROCESS_EVENTS.

When a foreign interpreter invokes this method, an !ERROR=208 Multi Thread results. See Accessing Objects From Different Interpreters.

Example

rem ' BBjRadioGroup

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(25,25,800,500,"BBjRadioGroup",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")

rem ' RadioGroup 1
rb1! = window!.addRadioButton(101,25,25,150,25,"RadioButton1",$0020$)
rb1!.setCallback(rb1!.ON_CHECK_ON,"event")
rb1!.setCallback(rb1!.ON_CHECK_OFF,"event")
rb2! = window!.addRadioButton(102,25,50,150,25,"RadioButton2",$0020$)
rb2!.setCallback(rb2!.ON_CHECK_ON,"event")
rb2!.setCallback(rb2!.ON_CHECK_OFF,"event")
rb3! = window!.addRadioButton(103,25,75,150,25,"RadioButton3",$0020$)
rb3!.setCallback(rb3!.ON_CHECK_ON,"event")
rb3!.setCallback(rb3!.ON_CHECK_OFF,"event")
rb4! = window!.addRadioButton(104,25,100,150,25,"RadioButton4",$0020$)
rb4!.setCallback(rb4!.ON_CHECK_ON,"event")
rb4!.setCallback(rb4!.ON_CHECK_OFF,"event")
rg1! = window!.addRadioGroup()
rg1!.setName("RadioGroup1",err=*next)
rg1!.add(rb1!)
rg1!.add(rb2!)
rg1!.add(rb3!)
rg1!.add(rb4!)

rem ' RadioGroup 2
rb5! = window!.addRadioButton(105,200,25,150,25,"RadioButton5",$0020$)
rb5!.setCallback(rb5!.ON_CHECK_ON,"event")
rb5!.setCallback(rb5!.ON_CHECK_OFF,"event")
rb6! = window!.addRadioButton(106,200,50,150,25,"RadioButton6",$0020$)
rb6!.setCallback(rb6!.ON_CHECK_ON,"event")
rb6!.setCallback(rb6!.ON_CHECK_OFF,"event")
rb7! = window!.addRadioButton(107,200,75,150,25,"RadioButton7",$0020$)
rb7!.setCallback(rb7!.ON_CHECK_ON,"event")
rb7!.setCallback(rb7!.ON_CHECK_OFF,"event")
rb8! = window!.addRadioButton(108,200,100,150,25,"RadioButton8",$0020$)
rb8!.setCallback(rb8!.ON_CHECK_ON,"event")
rb8!.setCallback(rb8!.ON_CHECK_OFF,"event")
rg2! = window!.addRadioGroup()
rg2!.setName("RadioGroup2",err=*next)
rg2!.add(rb5!)
rg2!.add(rb6!)
rg2!.add(rb7!)
rg2!.add(rb8!)

rem ' This BBjRadioGroup event is available in BBj 23.
rg1!.setCallback(rg1!.ON_SELECTION_CHANGE,"group",err=*next)
rg2!.setCallback(rg2!.ON_SELECTION_CHANGE,"group",err=*next)
events! = window!.addCEdit(900,25,150,750,325,$$,$0184$)
process_events

eoj:
release

resize:
    event! = sysgui!.getLastEvent()
    width = event!.getWidth()
    height = event!.getHeight()
    events!.setSize(width-50,height-175)
return

event:
    event! = sysgui!.getLastEvent()
    msg$ = event!.getEventName()+" "+event!.getRadioButton().getText()
    msg$ = msg$ + " " + event!.getRadioButton().getRadioGroup().getName(err=*next)
    print msg$
    events!.addParagraph(-1,msg$)
    events!.highlight(-1,0,-1,0)
return

group:
    event! = sysgui!.getLastEvent()
    group! = event!.getRadioGroup()
    selected! = event!.getSelected()
    if selected!=null() then selected$ = "" else selected$ = selected!.getText()
    deselected! = event!.getDeselected()
    if deselected!=null() then deselected$ = "" else deselected$ = deselected!.getText()
    msg$ = event!.getEventName()+" "+group!.getName(err=*next)
    msg$ = msg$+" selected="+selected$+" deselected="+deselected$
    print msg$
    events!.addParagraph(-1,msg$)
    events!.highlight(-1,0,-1,0)
return

See Also

BBjAPI

Object Variables

BBjRadioGroup::clearCallback

PROCESS_EVENTS Verb

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