We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Archicad C++ API
About Archicad add-on development using the C++ API.

Menu / Sub-menu structure

dushyant
Enthusiast
What guides the indenting of sub-menus? How to control which sub-menu can further have its own sub-menus?
8 REPLIES 8
Ralph Wessel
Mentor
Answered in this thread.
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
So I understand that nesting is not possible further than Menu > Menu Item > Sub Menu Item.

How do I get this kind of structure, keeping the same hierarchy level:

Menu 1 > Menu Item 1 > Sub Menu Item 1
Menu 1 > Menu Item 1 > Sub Menu Item 2
Menu 1 > Menu Item 2
Menu 1 > Menu Item 3 > Sub Menu Item 3
Menu 1 > Menu Item 4
Menu 1 > Menu Item 5

Thanks,
Dushyant Basson
Ralph Wessel
Mentor
Each item in your main menu, whether it is a single menu item or contains a submenu of items, should be a separate resource. For your example (in outline):

Resource 1
	Menu 1
	Menu Item 1
	Sub Menu Item 1
	Sub Menu Item 2
	
Resource 2
	Menu 1
	Menu Item 2
	
Resource 3
	Menu 1
	Menu Item 3
	Sub Menu Item 3
	
Resource 4
	Menu 1
	Menu Item 4
	
Resource 5
	Menu 1
	Menu Item 5
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
Okay. So far I have dealt only with one resource for menu, like this:

'STR#' ID_MENU_STRINGS_1 "Menu strings 1" {
/* [ ] */ "Menu 1"
/* [ ] */ "Menu Item 1"
/* [1] */ "Sub Menu Item 1"
/* [2] */ "Sub Menu Item 2"
}

Can you please give an example for how to set another resource for the following addition to the above menu:
Menu 1
Menu Item 2
Sub Menu Item 3

I tried like the following but that results in no menu at all for the add-on:
'STR#' ID_MENU_STRINGS_2 "Menu strings 2" {
/* [ ] */ "Menu 1"
/* [ ] */ "Menu Item 2"
/* [1] */ "Sub Menu Item 3"
}

Please help. Thanks.
Ralph Wessel
Mentor
The resource structure looks right. Are you registering both menu resources with ACAPI_Register_Menu and ACAPI_Install_MenuHandler?
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
I had missed out on ACAPI_Register_Menu and ACAPI_Install_MenuHandler.. The menu is drawn now.

RegisterInterface() is now like this:
GSErrCode err = ACAPI_Register_Menu (ID_MENU_STRINGS_1, ID_MENU_PROMPT_STRINGS_1, MenuCode_UserDef, MenuFlag_Default);
GSErrCode err2 = ACAPI_Register_Menu(ID_MENU_STRINGS_2, ID_MENU_PROMPT_STRINGS_2, MenuCode_UserDef, MenuFlag_Default);
return err, err2;

Hope that's the correct format. Please comment.

Thanks.
Ralph Wessel
Mentor
Yes, that's the right approach. Every menu resource must be independently registered and installed the same way. Make sure you also install the callback handler or nothing will happen when the menu is selected.
Ralph Wessel BArch
Software Engineer Speckle Systems
dushyant
Enthusiast
Yes, done that:

GSErrCode err1 = ACAPI_Install_MenuHandler (ID_MENU_STRINGS_1, MenuCommandHandler);
GSErrCode err2 = ACAPI_Install_MenuHandler (ID_MENU_STRINGS_2, MenuCommandHandler);
return err1, err2;