Ok sorry to resurrect this one as I'm sure one of you guys has already nailed it by now, but I thought I'd share my experience with this stuff.
I've just had to implement a preferences page in a plugin that I'm working on and of course, when it came to reading the items in the panel, I ended up here. I thought I'd hit a brick wall until a few hours ago when I made a bit of a breakthrough while I was actually writing a post to this thread asking for help!
I originally had the same trouble accessing the items in the panel as btemp did and found the functions GetPreferencePanelItemRef and GetPreferencePanelBaseItemIndex to be equally as useless. But after a bit of fiddling and a lot of swearing, I've finally managed to get notifications from the controls in my preference panel.
So here's how I did it:
Add your preferences panel in the usual way by adding a resource definition and calling sAIPreference->AddPreferencePanel
Catch the menu item message using the handle returned to you by AddPreferencePanel, more on this later.
Catch kAIPreferenceCaller - this wasn't handled by default in the SDK sample plugins so I added it myself.
Catch the following selectors:
kAIPreferenceInitSelector
kAIPreferenceOKSelector
kAIPreferenceCancelSelector
kAIPreferenceUpdateSelector
kAIPreferenceInitSelector - Called as your preference panel is first displayed. - It seems you only receive this selector if the user has used the keyboard shortcut to access the preferences pane. If the user has selected the menu item directly from the preferences menu, you will receive the menu item message.
On your kAIPreferenceUpdateSelctor handler you are passed an (AIPreferencePanelMessage*). Use this parameter to get a handle to the dialog as follows (or something like this):
ASErr MyPlugin::PreferenceUpdate(AIPreferencePanelMessage* message)
{
ADMItemRef baseItemRef = NULL;
sAIPreference->GetPreferencePanelItemRef(message->itemGroup, &baseItemRef);
if (baseItemRef != NULL)
{
IADMItem baseItem(baseItemRef);
// The baseItemRef is actually the dialog item here
IADMDialog prefsDialog(baseItem.GetDialog());
// These are just resource IDs from my plugin's .r file, just two radio buttons for now.
IADMItem firstRadioButton(prefsDialog.GetItem(kMyPluginPrefsPanelDialogID + kMyPluginPrefsFirstRadioButtonResourceID));
IADMItem secondRadioButton(prefsDialog.GetItem(kMyPluginPrefsPanelDialogID + kMyPluginPrefsSecondRadioButtonResourceID));
// Set the controls values, read your current preference values and populate the controls here
firstRadioButtonItem.SetBooleanValue(true);
secondRadioButtonItem.SetBooleanValue(false);
// Set your notification procedures and pass any data you may need (I'm passing "this" so I can call a member function later)
firstRadioButtonItem.SetNotifyProc(MyPlugin::FirstRadioNotifyProc);
firstRadioButtonItem.SetNotifierData(static_cast<void*>(this));
secondRadioButtonItem.SetNotifyProc(MyPlugin::SecondRadioNotifyProc);
secondRadioButtonItem.SetNotifierData(static_cast<void*>(this));
}
You may find that you receive this selector twice so just bear this in mind if you need to allocate memory.
Now you should receive notifications from the controls in your preference panel.
The kAIPreferenceOKSelector and kAIPreferenceCancelSelector are called when the user clicks Ok or Cancel (surprisingly!) so you have a chance to save or discard any changes the user has made. The AIPreferencePanelMessage* sent with these selectors contains an ADMItemRef which is an ADM group item which as btemp discovered, is pretty darn useless.
This might not be the way Adobe intended it to work but until they sort out the piss-poor documentation out, it works for me.
-W
Edit: Typos