4 Replies Latest reply on Mar 20, 2016 4:42 PM by Rick E Johnson

    Can't add items to existing sub-menu (CS6)

    Rick E Johnson Level 1

      I used to be able to easily add items to the Select -- Object sub-menu by adding menu items with the group name kSelectObjectMenuGroup, but no matter what approach I've tried, it either returns an error or the menu item simply doesn't appear. Is access to that menu no longer allowed (as of CS6)?

        • 1. Re: Can't add items to existing sub-menu (CS6)
          Toto RoToTO Level 3

          you should take a look at this:

           

              // Add an SDK menu group to the Windows menu.

              const char* kSDKWindowsMenuGroup = "SDKWindowGroup";

              bool exists = false;

              error = this->MenuGroupExists(kSDKWindowsMenuGroup, exists);

              aisdk::check_ai_error(error);

              if (!exists) {

                  AIPlatformAddMenuItemDataUS menuItemData;

                  menuItemData.groupName = kOtherPalettesMenuGroup;

                  menuItemData.itemText = ai::UnicodeString("SDK");   

                  AIMenuItemHandle menuItemHandle = nil;

                  error = sAIMenu->AddMenuItem(message->d.self, NULL, &menuItemData, kMenuItemNoOptions, &menuItemHandle);

                  aisdk::check_ai_error(error);

                  AIMenuGroup menuGroup = nil;

                  error = sAIMenu->AddMenuGroupAsSubMenu(kSDKWindowsMenuGroup, kMenuGroupSortedAlphabeticallyOption, menuItemHandle, &menuGroup);

                  aisdk::check_ai_error(error);

          }

          • 2. Re: Can't add items to existing sub-menu (CS6)
            Rick E Johnson Level 1

            Thanks, Thomas,

             

            That code didn't quite work for me, but it pointed me in the right direction. At the point where my plugin installs menus, there are 104 menu groups. The Select menu exists, but its Objects sub-menu doesn't (yet). Golly, who'd a thunk? It was there through CS5, but CS6 has sure been loaded with surprises.

             

            I suppose I could add that Object sub-menu myself and see if it causes a collision when Illustrator wants to add it later, but even if it worked, I'm sure my items would then be at the beginning of the list, not the end. I don't want that, nor do I want to add an additional sub-menu, but I guess the latter is at least a workable choice. ... Or perhaps my plugin could come back later to add its menu items. :-/

             

            Rick

            • 3. Re: Can't add items to existing sub-menu (CS6)
              Blyskawica Level 3

              I've run into this problem too.

               

              In the end I just substituted 'kSelectMenuExternalGroup' for 'kSelectObjectMenuGroup'. The menu items show up directly at the bottom of the Select menu (not as logical as in the 'Object' submenu), but at least it works and is simple to implement.

              • 4. Re: Can't add items to existing sub-menu (CS6)
                Rick E Johnson Level 1

                There may be a workaround I'll try later. There's a call to your plugin to a function "PostStartupPlugin()" as in the MultiArrowTool sample. This is called after the plugin is loaded. The FreeGrid and SnippetRunner samples both have functions to test for the existence of a menu group. I add this to my project and put this in PostStartupPlugin():

                 

                  ASErr result = kNoErr;

                  bool exists = false;

                  result = this->MenuGroupExists((const char*) kSelectObjectMenuGroup, exists);

                  return result;

                 

                It told me the group now exists.