What is New in MAXScript > What was New in MAXScript in Previous Versions > What was New in MAXScript in 3ds Max 8 > MAXScript Language Improvements in 3ds Max 8 >

# Fixed .Checked and .Enabled Properties in RCMenus

In 3ds Max 8 and higher, menu items in RCMenus used in dialogs will update correctly when the menuItem's .enabled and.checked properties change.

TEST CASE:
    try (destroyDialog ro_vPropShop3) catch ()
    rcmenu rc_Main
    (
      local testval = false
      subMenu "Options"
      (
        subMenu "Placement Options"
        (
          menuItem mi_align "Align to face"checked:testval
          menuItem mi_art "Make Art"
          menuItem mi_pict "Make Picture"checked:false
        )
      )
      menuItem mi_halt "Halt and Catch Fire"
      on mi_align picked do (print "picked";testval = not testval)
      on rc_Main open do (print "opened")
      on rc_Main update do (print "update")
    )
    rollout ro_vPropShop3 "vPropShop3"()
    createDialog ro_vPropShop3 width:600 height:400\
      bgColor:[153,153,153] menu:rc_Main \
      style:#(#style_titlebar, #style_sysmenu, #style_minimizebox, #style_resizing)

If you pick Options/Placement Options/Align to Face, and then open to that item again, it will be checked. Previously, it would show as unchecked. Picking the other items doesn't cause this to happen because the script need to set up a variable to track the state (testval for menuItem mi_align).

Note

When a RCMenu is used in a Dialog, the open handler is called once when the dialog is created.

## Added 'update' event handler to RCMenu.

This event handler is called when one of the top level subMenu or menuItems is initially clicked on. This event handler only called once per focus being set to the menu items - if you click on 'Options' the event handler is called, but it is not called when moving the mouse back and forth between 'Options' and 'Halt and Catch Fire' or clicking on menu items. This event handler is called after the enabled and checked keyword parameters are evaluated, and allows you to set new values for these properties. If a keyword parameter is not specified for the checked or enabled property, that property value is not changed when processing the keyword parameters (i.e. after initial creation there is no default value for these properties).

TEST CASE:
    rc_Main.mi_align.enabled = not rc_Main.mi_align.enabled

    rc_Main.mi_art.checked = not rc_Main.mi_art.checked
    rc_Main.mi_art.enabled = not rc_Main.mi_art.enabled

    rc_Main.mi_pict.checked = not rc_Main.mi_pict.checked
    rc_Main.mi_pict.enabled = not rc_Main.mi_pict.enabled

    rc_Main.mi_halt.checked = not rc_Main.mi_halt.checked
    rc_Main.mi_halt.enabled = not rc_Main.mi_halt.enabled

After running the above, all of the menuItems are disabled, 'Align to Face' and 'Make Art' are checked, and 'Make Picture' is unchecked. 'Make Picture' is unchecked because it has the keyword parameter: checked:false

Note that when a RCMenu is opened, its local variables are re-initialized.

AS SUCH, YOU CANNOT SAY:
    rcmenu MyRCmenu4
    (
      local isChecked = false
      menuItem mi_xx "test slot"checked:isChecked
      on mi_xx picked do isChecked = not isChecked
      on MyRCmenu4 open do (print "opened")
    )
    popupmenu MyRCmenu4
    popupmenu MyRCmenu4
because each time MyRCmenu4 is displayed isChecked is being set to false. Instead, you need to store the persistent state outside the scope of the RCMenu,
LIKE THIS:
    isChecked = false
    rcmenu MyRCmenu4
    (
      menuItem mi_xx "test slot" checked:isChecked
      on mi_xx picked do isChecked = not isChecked
    )
    popupmenu MyRCmenu4

#### See Also

- MAXScript Language Improvements in 3ds Max 8