Hot Door CORE Forum
Menu groups for several plug-ins - Printable Version

+- Hot Door CORE Forum (http://hotdoorcore.com/forum)
+-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1)
+--- Forum: Bugs (http://hotdoorcore.com/forum/forumdisplay.php?fid=5)
+--- Thread: Menu groups for several plug-ins (/showthread.php?tid=41)



Menu groups for several plug-ins - Gaxx - 11-12-2014

Hi. I have recently encountered this problem. I have compiled two different plug-ins using hdi. Both of them add a menu group and some elements to their respective groups. Problem is, all elements fom both plug-ins end up in one menu group if both plug-ins are added to illustrator. The other menu group stays empty.


RE: Menu groups for several plug-ins - garrett - 11-17-2014

This is strange behavior. Normally, if separate plugins use identical text values for a group (within the same parent), then only a single group will be created and all child menu items will be in the "unified" group. This is a feature of the Illustrator SDK itself.

If separate plugins use different text values or parent groups, then two groups will be created separately and of course each child menu item will only go into the individual group created by the plugin.

Can you post some sample code that exhibits the problem? Thanks.


RE: Menu groups for several plug-ins - Rick Johnson - 05-20-2016

It's nice that CORE checks for a menu group before creating another, but something's gone haywire. I created a plugin using the Adobe SDK and another with CORE for CS6, Mac. The application menu lists two menu groups for my About boxes, both spelled exactly alike. The Adobe SDK plugin code checks whether the group already exists before adding the group to the menu, so this shouldn't have happened. The SDK plugin appears higher in the menu than the CORE plugin; does the order indicate which was loaded first, and thus which plugin didn't recognize the duplicate group name?


RE: Menu groups for several plug-ins - Rick Johnson - 05-24-2016

Garrett, here's some code that creates duplicate menu groups. I have exactly the same code in two plugins, the only difference being the plugin name:

Code:
    this->__aboutMenuGroup = hdi::core::MenuGroup(
      hdi::core::AboutMenuGroup,
      "About Graffix Plugins");
    this->__aboutMenuItem = hdi::core::MenuItem(
        __aboutMenuGroup,
        "InCopy Text Link...",
        HDI_CORE_CALLBACK(gx::About, this, __aboutBoxCB)
    );

I have a namespace gx with a class "About" for a standardized About box layout and behavior. I'll send you the .cpp and .hpp files if you'd like.


RE: Menu groups for several plug-ins - garrett - 06-22-2016

After some experimentation, it appears as though this might be a bug in the underlying AIMenu suite in the Illustrator SDK. No workaround is immediately coming to mind, but I did notice that if one plugin initially creates the menu group with the "mergeTop_" parameter set to false and a secondary plugin creates the (same) menu group with the "mergeTop_" parameter set to true then it works as expected.

If both set "mergeTop_" to true then obviously whichever plugin loads first will create the group as fully merged with the parent, which is not desired. However, if the first plugin to load sets it to false then a new group is created, and all subsequent plugins setting it to true cause them to merge with the parent (yielding the desired menu item layout).

This is sort of a nasty solution, but for now it's all I can think of. And I say it's nasty because all of your plugins (that you want to share this menu group) will need to message one another immediately before creating the group to see if one has already done it. If not, set mergeTop_ to false, otherwise set it to true. This sort of messaging can be accomplished pretty easily with the hdi::core::ThirdPartyPlugin class and its message() method (and other supporting methods).


RE: Menu groups for several plug-ins - Rick Johnson - 07-26-2016

I see that as of CORE 0.6.2, "About" menu groups still pile up, with only the top one populated. If the SDK menu bug persists, may I request a counterpart to Adobe's "MenuGroupExists(kSDKWindowsMenuGroup, exists);"? In a similar fashion, I want to combine several of my plugins' tools in the same group, but can't find a simple method to do so. Would a CORE counterpart to Adobe's methods to find an installed tool by its name be feasible?

The ThirdPartyPlugin class seems like a reasonable workaround for both of these situations, if only I could figure out how to use it. It seems like it must require custom notifiers, etc. Might a secondary shared prefs file work as well, and be simpler to implement?


RE: Menu groups for several plug-ins - Rick Johnson - 08-27-2016

Still looking for a simple way to test for the existence of a menuGroup, I came up with this:

Code:
uint32_t mGroupIndex = -1;
uint32_t mGrpCount = HDI_CORE_ILLUSTRATOR-> menuGroupCount();
std::auto_ptr<hdi::core::MenuGroup> thisGrp;
if (mGrpCount>0) {
    for (int i = 1; i<mGrpCount; i++) {
        thisGrp = HDI_CORE_ILLUSTRATOR->menuGroupAtIndex(i);
        if (thisGrp->isPartial()) break;
        if (thisGrp->text()=="About Some Plugins"){
            AIMenuItemHandle aiHandle(thisGrp->aiMenuItemHandle());
            AIMenuGroup aiGroup(thisGrp->aiMenuGroup());
            this->__aboutMenuGroup = hdi::core::__accessCtor(aiGroup, aiHandle);
            mGroupIndex = i;
            break;
        }
    }
}

if (mGroupIndex<0) {
//  create new __aboutMenuGroup
}

It works! Would you consider this a desirable workaround to avoid multiple menu group items?


RE: Menu groups for several plug-ins - Rick Johnson - 08-29-2016

Oops, a uint32_t can't be negative, so I initialized mGroupIndex to 0, then later checked if it was still zero before making a new group. It's still working great. Smile


RE: Menu groups for several plug-ins - Rick Johnson - 05-02-2017

Is there a way to simulate a "mergeBottom_" counterpart to mergeTop_? I'd like to place a divider under the Illustrator prefs, then add my prefs below that at the bottom of the prefs menu.


RE: Menu groups for several plug-ins - garrett - 05-05-2017

I seem to remember trying to insert some menu items at the bottom of the preferences group when implementing our Menu* classes, but it wasn't possible through the Illustrator SDK. We keep our plugin's pref-related menu items at the top of the group with a divider at the bottom instead.