About   |   Getting Started   |   Downloads   |   Documentation   |   Forum


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Menu groups for several plug-ins
11-12-2014, 01:59 AM
Post: #1
Menu groups for several plug-ins
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.
Find all posts by this user
Quote this message in a reply
11-17-2014, 10:41 PM
Post: #2
RE: Menu groups for several plug-ins
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.
Find all posts by this user
Quote this message in a reply
05-20-2016, 04:30 PM
Post: #3
RE: Menu groups for several plug-ins
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?
Find all posts by this user
Quote this message in a reply
05-24-2016, 07:16 PM
Post: #4
RE: Menu groups for several plug-ins
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.
Find all posts by this user
Quote this message in a reply
06-22-2016, 03:59 PM
Post: #5
RE: Menu groups for several plug-ins
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).
Find all posts by this user
Quote this message in a reply
07-26-2016, 06:07 PM
Post: #6
RE: Menu groups for several plug-ins
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?
Find all posts by this user
Quote this message in a reply
08-27-2016, 07:44 PM
Post: #7
RE: Menu groups for several plug-ins
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?
Find all posts by this user
Quote this message in a reply
08-29-2016, 10:58 AM
Post: #8
RE: Menu groups for several plug-ins
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
Find all posts by this user
Quote this message in a reply
05-02-2017, 07:48 PM
Post: #9
RE: Menu groups for several plug-ins
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.
Find all posts by this user
Quote this message in a reply
05-05-2017, 04:38 PM (This post was last modified: 05-05-2017 04:38 PM by garrett.)
Post: #10
RE: Menu groups for several plug-ins
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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)