8 Replies Latest reply on Feb 12, 2016 1:38 AM by edwinc35713446

    Configure window title of hybrid extension

    edwinc35713446

      Hi,

       

      I have just completed work on a C++/JavaScript hybrid extension and have encountered a problem with extensions,which I am seeking help for.  Basically, the extension window has no title.

       

      Our requirement was to invoke the plug-in UI (implemented as an HTML5 extension) from the standard File menu, rather than from Window->Extensions.  I have successfully achieved this by adding menu entries from C++, and disabling the XML <menu> tag from the extension's manifest.

      The problem is that when disabling the menu entry from the manifest, the extension loses its window title.  Is there any way to specify a window title without having a menu entry in Window->Extensions?

       

      Regards,

      Ed

        • 1. Re: Configure window title of hybrid extension
          lesavage Adobe Employee

          Hi Ed,

           

          Unfortunately not. At the moment the only way to define the window title is by including the menu entry in the manifest file.

           

          Kind regards,

          Lea

          • 2. Re: Configure window title of hybrid extension
            edwinc35713446 Level 1

            Hi Lea,

             

            Thanks for confirming this.  I resolved the shortcoming by defining menu entries in the manifest and then programmatically finding and removing them on plugin load.  It was a bit of extra work, but achieves the required result of having an extension window with a title but no menu entry in Window->Extension.

             

            Regards,

            Ed

            • 3. Re: Configure window title of hybrid extension
              bprayit01

              Hi Ed.

               

              I've been struggling with the same issue for a hybrid extension that I am writing. Would it be possible for you to share your approach in more detail?

               

              Thanks,

               

              B.

              • 4. Re: Configure window title of hybrid extension
                Toto RoToTO Level 3

                I have not thought about that solution. But thanks to Ed, I have solve my issue.

                 

                Once everything is loaded and ready ( after being notified -fPlugPlugSetupCompleteNotifier), here is what I do:

                1- get menu items count,

                2- parse all menu items (loooooooop)

                     2-1 compare menu item string to the one I am looking for,

                          -> if it is the one: remove this menu item,

                          -> otherwise keep parsing.

                 

                3- Job done.

                    

                Sample Code:

                 

                AIErr error = kNoErr;

                ai::int32 count = 0;

                ai::int32 index = 0;

                ai::UnicodeString itemString;

                AIMenuItemHandle menuItem ;

                ai::UnicodeString extension_menu("extension title");

                 

                error = sAIMenu->CountMenuItems(&count);

                for (index; index < count; index++){

                     error = sAIMenu->GetNthMenuItem(index, &menuItem);

                     if (menuItem != nullptr){

                           error = sAIMenu->GetItemText(menuItem, itemString);

                 

                           if (itemString.compare(extension_menu) == 0){

                                error = sAIMenu->RemoveMenuItem(menuItem);

                          }

                     }

                }

                return error;

                 

                I hope this will help you!

                Thomas.

                • 5. Re: Configure window title of hybrid extension
                  Toto RoToTO Level 3

                  you should also considering the menu group your menu item is in.

                  Remove only the menu item from the extension menu item group.

                  You could do that using the menu group name.

                   

                  Thomas.

                  • 6. Re: Configure window title of hybrid extension
                    bprayit01 Level 1

                    Thank you Thomas... this has been really useful! Will let you know how I get on with your approach.

                     

                    Thanks,

                     

                    B.

                    • 7. Re: Configure window title of hybrid extension
                      Toto RoToTO Level 3

                      Set and Get the title of the extension windows

                      (Since 6.1)

                       

                      CEP 6.1 introduces two APIs to set and get the title of extension windows. Those functions work with modal and modeless extensions in all Adobe products, and panel extensions in Photoshop, InDesign, InCopy, Illustrator, Flash Pro and Audition:

                      CSInterface.prototype.setWindowTitle = function(title){

                          window.__adobe_cep__.invokeSync("setWindowTitle", title);

                      };

                       

                      CSInterface.prototype.getWindowTitle = function(){

                          return window.__adobe_cep__.invokeSync("getWindowTitle", "");

                      };

                       

                      Thomas.

                      • 8. Re: Configure window title of hybrid extension
                        edwinc35713446 Level 1

                        It's been several months since I last logged in here and I missed the posts from you guys.  The new CEP title setting API's are a much better implementation, and I plan to switch to using them for the CC2015 rewrite I'm doing.

                         

                        For reference, here's my C++ code.  In concept it's similar to Thomas' code, but removes only menus in a specific group and also adds a disabled menu so that we never have an empty Windows -> Extensions group if there are no other extensions installed.  Code could be made shorter but I opted to split the process in two passes: search pass; remove pass.

                         

                        Ed

                         

                        ASErr MyPlugin::FixupExtensionMenus()
                        {
                        ASErr error = kNoErr;

                        int32_t cnt;
                        int32_t* p_cnt = &cnt;

                        AIMenuItemHandle menuItem;
                        AIMenuGroup menuGroup;
                        ai::UnicodeString menuText;
                        std::stack<AIMenuItemHandle> itemsToRemove;
                        AIPlatformAddMenuItemDataUS dummyMenu;
                        AIMenuItemHandle dummyMenuItem;

                        const char* menuGroupName;
                        error = sAIMenu->CountMenuItems(p_cnt);
                        if (error) goto error;

                        for (int idx = 0; idx< cnt; idx++)
                        {
                          // get menu item
                          error = sAIMenu->GetNthMenuItem(idx, &menuItem);
                          if (error) goto error;

                          // get item's group
                          error = sAIMenu->GetItemMenuGroup(menuItem, &menuGroup);
                          if (error) goto error;

                          error = sAIMenu->GetMenuGroupName(menuGroup, &menuGroupName);
                          if (error) goto error;

                          // check if group is within Services Menu Group
                          if (strcmp(menuGroupName, kServicesMenuGroup) == 0)
                          {
                           error = sAIMenu->GetItemText(menuItem, menuText);
                           if (error) goto error; 

                           // tag specific menus for removal.
                           // ATTENTION: the match string must be copied exactly from extension's manifest.xml file
                           if ((menuText.compare(ai::UnicodeString("Match string 1")) == 0) ||
                            (menuText.compare(ai::UnicodeString("Match string 2")) == 0))
                           {
                            itemsToRemove.push(menuItem);
                           }
                          }
                        }

                        // remove tagged menus
                        AIMenuItemHandle itemToRemove;
                        while (!itemsToRemove.empty())
                        {
                          itemToRemove = itemsToRemove.top();
                          itemsToRemove.pop();

                          if (itemToRemove != NULL)
                          {
                           error = sAIMenu->RemoveMenuItem((AIMenuItemHandle)itemToRemove);
                           if (error) goto error;
                          }
                        }

                        // Add a dummy menu so that we don't leave the Extensions group menu without entries

                        dummyMenu.groupName = kServicesMenuGroup;
                        dummyMenu.itemText = ai::UnicodeString(kMyPluginSDKString); 
                        error = sAIMenu->AddMenuItem(this->GetPluginRef(), kServicesMenuGroup, &dummyMenu, 0, &dummyMenuItem);
                        if (error) goto error;

                        error = sAIMenu->DisableItem(dummyMenuItem);
                        if (error) goto error;

                        error:
                        return error;
                        }