RToggle Gadgets
- Last UpdatedNov 13, 2025
- 2 minute read
The RTOGGLE gadget is very similar to the TOGGLE gadget, but is allowed only in FRAMEs, where they operate together to form a set of radio buttons, only one of which can be selected at any one time.
You can add RTOGGLE gadgets to a FRAME with the usual layout and positioning commands. The RTOGGLE gadgets are implicitly numbered 1, 2, 3, ¼ n as they are added.
RToggle Callbacks
The RTOGGLE gadget can have an assigned callback, which is executed whenever its selected status is changed. When the group selection is changed, by the user clicking an unselected radio button, the current button (if any) is unselected and the new button is selected. An open callback (PML function or form method) is necessary as the events UNSELECT and SELECT need to be reported.
The PML code below shows a modification to our example form, which makes use of open callbacks on the RTOGGLEs instead of a simple callback on the FRAME radio group. The Constructor and the RgroupSelectionChanged methods are modified accordingly.
Note: The behavior of the two versions is identical. Both mechanisms are equally valid, and are provided to minimize the work required in replacing the RGROUP and (deprecated) RADIO gadgets.
define method .FRGTest()
-- Constructor
-- Frame radiogroup
-- set result field read-only
!this.choice.setEditable(false)
--TV and Radio with open callbacks
!this.rad1.callback = '!this.RGroupSelectionChanged('
!this.rad2.callback = '!this.RGroupSelectionChanged('
this.rad3.callback = '!this.RGroupSelectionChanged('
this.rad4.callback = '!this.RGroupSelectionChanged('
this.rad5.callback = '!this.RGroupSelectionChanged('
-- Radio choices
!this.rad5.setTooltip(|select your Radio option|)
!radio[1] = 'Q103'
!radio[2] = 'Hereward'
!radio[3] = 'Cambridge'
!radio[4] = 'ClassicFM'
!radio[5] = 'Caroline'
!this.Radio.dtext = !radio
!this.Radio.setTooltip(|change your Radio option|)
!this.Radio.callback = '!this.selectProgram(!this.rad5)'
-- set initial value
!this.rad2.val = true
!this.RGroupSelectionChanged( !this.rad2,'SELECT' )
endmethod
define method .RGroupSelectionChanged( !rtog is GADGET, !event is STRING )
-- Service specified radio-toggle events
if( !event eq 'UNSELECT' ) then
-- Do some application actions
!this.choice.clear()
elseif( !event eq 'SELECT' ) then
!value = !rtog.onValue
-- Do some application actions
if( !value eq 'radio' ) then
!value = !this.Radio.selection('dtext')
endif
!this.choice.val = !value
endif
endmethod
Order of Event Generation
Events for the radio group FRAME and its radio-toggles happen in the following order, when an RTOGGLE is selected:
UNSELECT on previously selected RTOGGLE (if any)
SELECT on new RTOGGLE
SELECT on FRAME