Hi there,
In the popup menu, I’m looking to “deactivate” the command if the a test of a valid selection is not valid
UI.add_context_menu_handler do |popup|
if validSelection
popup.add_separator
popup.add_item("Command1") { Command1 }
popup.add_item("Command2") { Command2 }
end
end
If validSelection is False, I wanted to “grey” the Command1 and Command2 in the popup like it was deactivated.
It isn’t clear from your snippet what Command1 and Command2 are or where they came from. If they are UI:Comand objects, you can set their validation proc.
Please do NOT do this. It is not a popup menu. It is the Context Menu.
This means that ONLY commands that apply to the current context should appear on the context menu.
So your original snippet which wraps the addition of the commands to the menu in a contextual (valid selection) test is correct.