Ok, I've got the menu but for some reason notfications are being sent back to the Item, not the entry/list's. This is what I have so far
In the dialog i create the Item:
g->cMenu = sADMDialog->CreateItem(reference,kADMUniqueItemID,kADMPopupMenuType,&button,ChanMenuInit,NULL,0);
The item is a button with an arrow that points to the right. when clicked it pops a menu out to the right that has two columns.
The Item's init function is this:
static
ADMErr ADMAPI ChanMenuInit(ADMItemRef inItem){g->list = sADMItem->GetList(inItem);
for(int i = 0; i < g->numChannels; i ++){g->MenuItems = sADMEntry->Create(g->list);
}
sADMList->SetNotifyProc(g->list,MenuChannelCatch);
sADMEntry->SetText(g->MenuItems[1],
"1");sADMEntry->SetText(g->MenuItems[2],
"2");sADMEntry->SetText(g->MenuItems[3],
"3");sADMEntry->SetText(g->MenuItems[4],
"4");sADMEntry->SetText(g->MenuItems[5],
"5");
return kNoErr;
}
This shoudl create 5 Entries into the list (which it does); however, each entry is blank with no value. When clicked a notifier for the button is triggered, not the list (I put the button notifier after noticing that that the list wasn't doing anything). I'm probibly missing some kind of Init procedure, any ideas?
Well, I don't use the same method for creating my pop-up menu. I do something slightly different, and maybe it makes a difference. I should note that I'm using the IADM* objects too, so there may be subtle differences -- they generally wrap to the obvious suite call though. Note also that I'm updating a list based on other events, so you can probably ignore clearing part
--------- snip ---------
IADMItem button(GetItem(kChangeMapViewButton));
IADMList list(button.GetList());
const int count = list.NumberOfEntries();
// clear list
for (int i = 0; i < count; i++) {
list.RemoveEntry(0);
}
// get my view list (what the views are is unimportant to you!)
const CString kSentToTemplate = QObject::tr("Switch to \"%1\"");
MapViewList::iterator index;
for (index = viewList.begin(); index != viewList.end(); ++index) {
int position = list.NumberOfEntries();
IADMEntry entry(list.InsertEntry(position));
CMapView* view = *index;
// CPlatformString is my own home-cooked class for converting between our
// internal string object & Adobe's ASUnicode (returned via au_atr())
CPlatformString text = kSentToTemplate.arg(view->GetName());
entry.SetText(text.au_str());
entry.SetUserData((void*)view);
entry.SetID(position);
}
--------- snip ---------
I think that setting the ID is critical to actually knowing which menuitem was hit -- I think they're all zero by default, which is part of the problem. I could be wrong though. I remember I wrestled with this a fair bit before I got it right. It maybe that asking for the ActiveEntry() is sufficient (as you'll see below). Still, setting an ID that means something is bound to be useful if you're not using the Get/SetUserData() calls.
To determine which entry was clicked, I respond to the item changed notifier (which you said you're getting). That looks kind of like this:
--------- snip ---------
IADMItem button(GetItem(kChangeMapViewButton));
IADMList list(button.GetList());
ADMEntryRef entryRef = list.GetActiveEntry();
if (entryRef) {
IADMEntry entry(entryRef);
// I'm using the user data so I don't actually care which entry was clicked
void* data = entry.GetUserData();
// you could ask for the ID at this point and that would tell you the index into the list;
// nothing stops you from making the IDs whatever you want though, if they're
// hard-coded
const int id = entry.GetID();
// respond
}
--------- snip ---------
FYI, the button in question is of type "ADM Popup Menu Type", at least in my resource file. I'm pretty sure that corresponds to a type in the ADMItem.h header if you search for it though. I don't know if you're using the same type of button or not though. Still, it's likely very similar.