Removing submenu item

MikeDMikeD Posts: 81

I have used a variation of Robs "Create Custom Action" (http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/actions/action_custom_create/start) in order to add a custom action at "&Scripts/VendorName" position of the main menu.


The problem is that there is no remove submenu method in the DzActionMenu Object. I have placed a 'Remove Action from menu' button, if a customer wants to remove it from the menu, but I managed to remove the action but not the "VendorName" submenu. So even if the submenu "VendorName" is empty, it is still under the "&Scripts" menu.

 

In the following code I collected the menu items into an array and I reverse it (so the last submenu item appears firstly):
 

//iterate over the items
for (var i=0; i<aMenuItems.length; i+=1){
	//check if the menu item has no items
	if (!aMenuItems[i].hasItems() ){
					
		//clear it
		delete aMenuItems[i];
										
	}else{
		//some menus has items
		break;
	}
}

 

The 'delete' method didn't work. The aMenuItems[i].deleteLater either. The aMenuItems have no labels or even unique names (all of them appeared as 'ActionMenu').

 

I could use the

 

aMenuItems[i+1].clear();

 

but it will delete every action and submenu even from the main "Script" menu. Then I could rebuild the menu by the actions in the action manager, but I don't think this is the right way.

 

 

Thanks a lot for any ideas you may have about it...

Post edited by MikeD on
Sign In or Register to comment.