Toggle Menus
- Last UpdatedNov 12, 2025
- 1 minute read
A menu TOGGLE field is a menu field with a callback action and a tick-box to show that the field has been selected or unselected.
By default the field will be unselected so the box will not be ticked. When picked the fields callback action will be executed and the tick-box ticked.
If you pick the field again the callback action will again be executed and the tick removed.
Note that the open callback is an obvious candidate for toggle menus as the SELECT or UNSELECT action is returned as the second argument to the callback method. See PML Functions and Methods
For example, in your form definition you can add a toggle field as follows:
setup form !!Myform Dialog size 30 5
. . .
!menu = !this.newmenu(‘Test’, ‘popup’)
!menu.add( 'Toggle' ,’Active/Inactive’, '!this.toggle(‘, 'OnOff' )
. . .
exit
. . .
define method .toggle( !menu IS MENU, !action IS STRING )
!name = !menu.fullname()
!field = !menu.PickedFieldName
$P menu $!name $!action field: $!field
endmethod
Note: How we use the PickedFieldName member of the menu object to obtain the last picked field.
If you pick this menu field the callback method will print:
menu !!MyForm.Menu1 SELECT field: OnOff