Sub OnGetItemPopup(Sender: Object; Args: IMetabaseListViewItemPopupEventArgs);
Begin
//set of operators;
End Sub OnGetItemPopup;
Sender. The parameter that returns the component that generated the event.
Args. The parameter that enables the user to determine event parameters.
The OnGetItemPopup event occurs when the context menu for the component element is being called.
The element, for which the context menu is called, is available in the IMetabaseListViewItemPopupEventArgs.Item property. Use the IMetabaseListViewItemPopupEventArgs.PopupMenu property to determine proper context menu, which will be displayed for the element.
If the IMetabaseListView.EnableSystemPopupMenu property is set to True for the component, the system context menu is called for elements. In this case, use the IMetabaseListViewItemPopupEventArgs.PopupMenu property to replace the called system context menu.
Executing the example requires a form, a button named Button1 on it, the MetabaseListView component named MetabaseListView1 and two PopupMenu components named PopupMenu1 and PopupMenu2. Add a link to the Metabase system assembly.
Sub MetabaseListView1OnGetItemPopup(Sender: Object; Args: IMetabaseListViewItemPopupEventArgs);
Var
MDesc: IMetabaseObjectDescriptor;
Begin
MDesc := Args.Item.ObjectDescriptor;
If MDesc.ClassId = MetabaseObjectClass.KE_CLASS_STDDIM Then
Args.PopupMenu := PopupMenu1;
Elseif MDesc.ClassId = MetabaseObjectClass.KE_CLASS_CLNDIM Then
Args.PopupMenu := PopupMenu2;
End If;
End Sub MetabaseListView1OnGetItemPopup;
While the form is processed, if context menu is called for table and calendar dictionaries, the menus generated in the PopupMenu1 and PopupMenu2 components will be displayed correspondingly.
See also: