Extended Host callback interface IComponentHandler3 for an edit controller.
- [host imp]
- [extends IComponentHandler]
- [released: 3.5.0]
A Plug-in can ask the host to create a context menu for a given exported Parameter ID or a generic context menu.
The host may pre-fill this context menu with specific items regarding the parameter ID like "Show automation for parameter", "MIDI learn" etc...
The Plug-in can use the context menu in two ways :
- add its own items to the menu via the IContextMenu interface and call IContextMenu::popup(..) to pop-up it. See the Example.
- extract the host menu items and add them to its own created context menu
Note: You can and should use this even if you don't add your own items to the menu as this is considered to be a big user value.
- See also
- IContextMenu
-
IContextMenuTarget
Example
Adding Plug-in specific items to the context menu
class PluginContextMenuTarget : public IContextMenuTarget, public FObject
{
public:
PluginContextMenuTarget () {}
{
switch (tag)
{
case 1: break;
case 2: break;
}
}
OBJ_METHODS(PluginContextMenuTarget, FObject)
DEFINE_INTERFACES
DEF_INTERFACE (IContextMenuTarget)
END_DEFINE_INTERFACES (FObject)
REFCOUNT_METHODS(FObject)
};
void popupContextMenu (IComponentHandler* componentHandler, IPlugView* view, const
ParamID* paramID,
UCoord x,
UCoord y)
{
if (componentHandler == 0 || view == 0)
return;
FUnknownPtr<IComponentHandler3> handler (componentHandler);
if (handler == 0)
return;
IContextMenu* menu = handler->createContextMenu (view, paramID);
if (menu)
{
PluginContextMenuTarget* target = new PluginContextMenuTarget ();
IContextMenu::Item item = {0};
item.tag = 1;
menu->addItem (item, target);
item.tag = 2;
menu->addItem (item, target);
target->release ();
menu->popup (x, y);
menu->release ();
}
}
Back to Contents