RToggle Callbacks
- Last UpdatedOct 30, 2024
- 1 minute read
The RTOGGLE gadget can have an assigned callback, which is executed whenever its selected status is changed. When the group selection is changed, by you clicking an unselected option 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