Copy link to clipboard
Copied
Hi,
I am working on a plugin for adobe illustrator 2022 by using adobe 2022 SDK.
I want to create menu item in the Edit Colors Menu.
I have used the following code for this:
______________________________________________________________________________
AIMenuItemHandle swapFillStrokeMenu;
ZRef zStringKey = ZREF("Swap Fill and Stroke");
error = sAIMenu->AddMenuItemZString(message->d.self, NULL, kAdobeColorFiltersMenuGroup, zStringKey, kMenuItemWantsUpdateOption, &swapFillStrokeMenu);
______________________________________________________________________________
But I have nothing as output. Can anyone please suggest me that what should I do in this code?
Thanks in advance
Kuo
Copy link to clipboard
Copied
I don't see anything wrong with your code, though I've never used the ZString version. The documentation in AIMenuGroups.h is a bit confusing, talking about `priority` which as I'm sure you already know is not in the SDK anymore, assuming it ever was.
One thing to consider is that these menuitems are added by plugins, as 90% of AI's UI is governed by first party plugins. It's not impossible that you're trying to add your menuitem before the official plugin has had a chance to add it. You could verify it exists by actually iterating its parent menu and making sure it's there, as a sanity check.
If it's not there when your plugin runs, there are tricks to push your plugin to the back of the load queue which would probably solve that problem.
Copy link to clipboard
Copied
I verified the menugroup & its parent menu in AddMenus. kEditMenuGroup exists, and kAdobeColorFiltersMenuGroup does not. I successfully added my menuitem in UpdateMenuItem. While it works, this method doesn't seem very formal. Is this the tricks you mentioned? Or is there a better way to tell me?
Sincerely thank you for the answer, it gave me the right direction.
Copy link to clipboard
Copied
I can't remember off the top of my head and I can't find a reference to it our code anywhere presently. I'm 95% sure that during startup there's a way to say "Not yet, try again later" and it will queue your plugin at the end of the load list. The idea is supposed to be that you may rely on suites that have not been exported yet because the plugin that exports them haven't been loaded.
E.g. You might try to load the AISymbolsSuite and fail; so you ask it to try again at the end, and then it does work because the Symbols.aip has been loaded. I just can't remember exactly how to do that
Copy link to clipboard
Copied
Thanks for the tip, I think I found a way.
I changed the code and it worked.
The following code I wrote in PostStartupPlugin()
kAdobeColorFiltersMenuGroup exists here.
AIMenuItemHandle swapFillStrokeMenu;
ZRef zStringKey = ZREF("Swap Fill and Stroke");
error = sAIMenu->AddMenuItemZString(fPluginRef, NULL, kAdobeColorFiltersMenuGroup, zStringKey, kMenuItemWantsUpdateOption, &swapFillStrokeMenu);
Copy link to clipboard
Copied
I think you are right. Whether written in UpdateMenuItem() or PostStartupPlugin(), I can't find my menu in the keyboard shortcuts dialog. I have to find the way you mentioned.
Copy link to clipboard
Copied
It should end up in the shortcuts dialog automatically. I doubt the timing of adding the menuitem affects that. Make sure you explore the shortcut dialog fully; I feel like I thought the same thing the first time I checked and later discovered that the UI doesn't show plugin shortcuts unless you pick some option -- I could be wrong though! It has been a while.