Context menus for results are tied to main tabs.
1.In xxx_TabItems.xml file locate the definition of results (<l:ShellResultView Style="...) where you want to add a popup menu, and look for the RightMouseClickCommandParameter statement. If there's one, its value points to the add-in script that calls the menu. If you can't find one, then look for the LeftDoubleClickCommandParameter within same results definition, and - if you find it - add the line: RightMouseClickCommandParameter="<scriptname>" replacing the <scriptname> with the name of the script you are going to create in the step 3. If neither LeftDoubleClickCommandParameter can be found, than look at the closest (upwards) <l:ShellResultView line, and then add the RightMouseClickCommandParameter statement as its attribute. Assuming you are about to add the context menu to the Content navigator, you may specify something like: RightMouseClickCommandParameter="ContentNavTabPopup"
" <summary>Called from a right mouse click in the Content navigator listing.</summary> Public Sub ShowContentNavTabPopup() Main.ShowPopupMenu("ContentNavTabPopup", True) End Sub In this example, the file is Ted.vb, and the class is Ted4MainAddIn.
Add the context menu definition, such as: <ContextMenu Name="ContentNavTabPopup" xmlns:l="http://www.teradp.com/schemas/GN4/1/Shell/Presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <l:ShellMenuItem Header="Open for Editing" CommandParameter="OpenDesigner"/> <l:ShellMenuItem Header="Open for Viewing" CommandParameter="ViewDesigner"/> <Separator/> <l:ShellMenuItem Header="Send" CommandParameter="Send"/> <l:ShellMenuItem Header="Delete" CommandParameter="ArticleSpike"/> <Separator/> <l:ShellMenuItem Header="Properties" CommandParameter="EditObject"/> </ContextMenu> Import the xxx_TabItems.file in the GN4 database, and recompile add-ins. A smarter context menu for results The above solution is simple, but it has a drawback: while displayed content can contain articles, stories, images, imgs, audios, videos, only articles can be opened (without 3rd party solutions). So, you may want to provide a context menu that will contain "open" commands for articles, but leave them out if the content is not an article. Two changes are needed: 1. The script becomes longer and checks if all selected items are of the article type - if so, it displays the menu ContentNavTabPopupArticle, otherwise, it displays another menu (without open commands): ContentNavTabPopupOther: " <summary>Called from a right mouse click in the Content navigator listing.</summary> Public Sub ShowContentNavTabPopup() If Main.GetSelectedObjects Is Nothing Then Return Dim bAllOpenable As Boolean = True For Each selectedObject In Main.GetSelectedObjects If Not selectedObject.IsKindOf("article") Then bAllOpenable = False Exit For End If Next If bAllOpenable Then Main.ShowPopupMenu("ContentNavTabPopupArticle", True) Else Main.ShowPopupMenu("ContentNavTabPopupOther", True) End If End Sub
<ContextMenu Name="ContentNavTabPopupArticle" xmlns:l="http://www.teradp.com/schemas/GN4/1/Shell/Presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <l:ShellMenuItem Header="Open for Editing" CommandParameter="OpenDesigner"/> <l:ShellMenuItem Header="Open for Viewing" CommandParameter="ViewDesigner"/> <Separator/> <l:ShellMenuItem Header="Send" CommandParameter="Send"/> <l:ShellMenuItem Header="Delete" CommandParameter="ArticleSpike"/> <Separator/> <l:ShellMenuItem Header="Properties" CommandParameter="EditObject"/> </ContextMenu> <ContextMenu Name="ContentNavTabPopupOther" xmlns:l="http://www.teradp.com/schemas/GN4/1/Shell/Presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <l:ShellMenuItem Header="Send" CommandParameter="Send"/> <l:ShellMenuItem Header="Delete" CommandParameter="ArticleSpike"/> <Separator/> <l:ShellMenuItem Header="Properties" CommandParameter="EditObject"/> </ContextMenu> |
The ability to display a context menu is available in the ResultListDesigner. By default this calls the AddIn command ShowResultListDesignerContextMenu in class MainAddIn in Shell.vb: <ShellCommand()> _ Public Sub ShowResultListDesignerContextMenu() Dim resultList As ShellResultView = Main.GetResultView()
If resultList IsNot Nothing Then Dim menuName As String = Nothing Dim dirStyle As DirectoryStyle = resultList.SelectedDirectoryStyle
If dirStyle IsNot Nothing Then menuName = dirStyle.ContextMenuName End If
If String.IsNullOrEmpty(menuName) Then Dim baseQuery As BaseQuery = resultList.BaseQuery
If baseQuery IsNot Nothing Then menuName = baseQuery.ContextMenuName End If
End If
If String.IsNullOrEmpty(menuName) Then menuName = "ResultListPopup" End If
If menuName IsNot Nothing Then Main.ShowPopupMenu(menuName, True) End If End If End Sub The above is called with right-clicking on a result listing in the result list designer (Shell main tab listings). The default ResultListPopup context menu unless overridden by the ContextMenu property on the current DirectoryStyle or current BaseQuery. |
See also