Notifications
Clear all

[Closed] How to enable/disable menu items?

I’m having trouble updating a menu on a rollout. When I have something selected I want “model selected” under the “tools” menu to be enabled. When nothing is selected I want it disabled.

Why doesn’t the menu update?


rcMenu TopMenu
(
subMenu "Tools"
(
menuItem menu_sel "model selected" enabled:false
)
on TopMenu open do
(
sel = (selection.count == 1)
menu_sel.enabled = sel
)
)
 
rollout new_rollout "Test"
(
)
 
createDialog new_rollout 150 150 menu:TopMenu
 

1 Reply

this code might prod u in the right direction…

rollout sel_test "sel_test"
(
label sel_txt ""
on sel_test open do
 (
 -- we use a [WHEN] construct to check for selection changes in the scene
 when select $* changes id:#sel_test_obj obj do
  (
  -- the contruct runs this argument and returns [obj] as the item de/selected
  sel_count =  selection.count as string
  the_caption = ("There are " + sel_count + " item(s) selected.")
  sel_txt.caption = the_caption
  )
 )
)
createdialog sel_test width:200

i hope this helps!