The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: ejrolon, Barry Kelly, Karl Ottenstein, LaszloNagy, gkmethy, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik, Tibor Lorántfy, rmasaki

By dushyant
#308313
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
User avatar
By Ralph Wessel
#308317
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):
Code: Select all
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
By dushyant
#308352
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.
User avatar
By Ralph Wessel
#308360
The resource structure looks right. Are you registering both menu resources with ACAPI_Register_Menu and ACAPI_Install_MenuHandler?
By dushyant
#308363
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.
User avatar
By Ralph Wessel
#308366
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.
By dushyant
#308369
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;