Copy link to clipboard
Copied
How to create Popup context menus for a button,same as this:

Copy link to clipboard
Copied
Windows or Mac? On Windows, you have to add a line for your button that looks like this to the DIALOG resource section for your panel:
CONTROL "Custom1",kThisIsTheButtonId,"ADM Popup Menu Type",WS_TABSTOP,118,92,19,16
The key bit is that (a) its CONTROL and (b) the class is "ADM Popup Menu Type". Its different for Mac, but its a pain so I won't go into that unless you need it.
Regardless of platform, after that, you do something like this (I'm using hte IADM* classes, but they're just wrappers):
// this assumes you're inside an IADMDialog derivitive, so I can use GetItem()
IADMItem button(GetItem(kThisIsTheButtonId));
IADMList list(button.GetList());
// this clears the list, but you only need to do this if you're updating it based on user interaction; ignore the next
// four lines if you're just setting your list once
const int count = list.NumberOfEntries();
for (int i = 0; i < count; i++) {
list.RemoveEntry(0);
}
// end of clear code
IADMEntry entry(list.InsertEntry(0));
entry.SetText("Test item");
entry.SetID(0); // pick a value for when its clicked so you know what was clicked
// you can also use SetUserData() if you want to associate it with data
Lastly, you watch for the 'item changed notifier' as usual and look for kThisIsTheButtonId. If the the pop-up menu is clicked, you'll get that as your item ID. To figure out which menuitem was clicked though, you then do something like this:
IADMItem button(GetItem(kThisIsTheButtonId));
IADMList list(button.GetList());
ADMEntryRef entryRef = list.GetActiveEntry();
if (entryRef) {
IADMEntry entry(entryRef);
int clickedId = entry.GetID(); // here's how you tell
}
Copy link to clipboard
Copied
thank you
Copy link to clipboard
Copied
hi,A. Patterson:
I ran into another problem,I have successfully created Popup context menus for a button with ai sdk,but how create menus item container ? same as:

Copy link to clipboard
Copied
I'm not sure if its possible to do that. I can't find an API for creating a sub-menu anywhere.The example you've posted is a special case -- that actually reflects the file system (it loads a directory for pre-defined swatches).
Copy link to clipboard
Copied
There are many popup menus whit sub-menu in ai ,see:


Copy link to clipboard
Copied
That's true, but I've still never figured out how to do that. I'm not saying its not doable, I'm saying I can see no way to do it. It'd have to be in ADMList.h or ADMEntry.h and neither seems to have anything for making an entry that is also an AMDList (or has one associated with it). There's got to be an API for it somewhere, but it may not be part of the public API. That's rare, but it does happen.
Copy link to clipboard
Copied
kADMHierarchyPopupCreateOption
This option seems to be useful,I have using it create a pop menu,but when I click the button, the system crash.
Copy link to clipboard
Copied
Interesting! That's something I never discovered, so I tip my hat to you! As for the crash, I don't know, since I've never tried it. I'm leaving for the day, but I'll try and take a look at the documentation tomorrow and see if I can figure out how it would be used; we can share approaches then and see if you've missed anything.
Copy link to clipboard
Copied
haha ,I have successfully create sub popup menus.
1: using kADMHierarchyPopupCreateOption option create Popup menus button.
2: set item style .sADMItem->SetItemStyle(Item,kADMPictureButtonHierarchyPopupMenuStyle);
3: ADMHierarchyListRef hierarchyListref = sADMItem->GetHierarchyList(item);
4:
ADMListEntryRef listEntryref;
listEntryref = sADMHierarchyList->InsertEntry( hierarchyListref ,0 );
sADMListEntry->SetText( listEntryref," sub menu" );
IADMHierarchyList panelMenuList1(sADMListEntry->CreateChildList(listEntryref));
listEntryref = panelMenuList1.InsertEntry(0);
sADMListEntry->SetText( listEntryref,"menu1" );
Copy link to clipboard
Copied
Ah, a Hierarchy list! Clever, that makes sense! Nice work!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more