03-02-2022 12:47 PM
Is there any way to customize/ alter the buttons that pop up when you right click on a channel in the data portal. Specifically adding custom functions such as invert or other mathematical functions?
Solved! Go to Solution.
03-09-2022 03:00 AM
Hi BrandonHosken,
The context menu in the dataportal is adjusted to the current mouse position. This means that it will compile the content dynamically. For this reason, it is not possible to customize this context menu except to add custom menu items at the bottom. Here is an example:
Call AddUserCommandToEvent("Portal.Events.OnShowingContextMenu","MyPortalOnShowingContextMenu")
Call AddUserCommandToEvent("Portal.Events.OnContextMenuPointSelected","MyPortalOnContextMenuPointSelected")
Sub MyPortalOnShowingContextMenu(ParentObj, MenuPoints)
If (ParentObj.IsKindOf(ePortalList)) Then
Call MenuPoints.Add("My Portal List Menu", 1)
End If
If (ParentObj.IsKindOf(ePortalStructure)) Then
Call MenuPoints.Add("My Portal Structure Menu", 2)
End If
End Sub
Sub MyPortalOnContextMenuPointSelected(ParentObj, MenuPoint)
Select Case MenuPoint.ID
Case 1 Call MsgBoxDisp("DIAdem-Portal: My List Menu selected")
Case 2 Call MsgBoxDisp("DIAdem-Portal: My Structure Menu selected")
End Select
End Sub
Greetings
Walter
03-09-2022 08:01 AM
This code runs successfully in the scripting tab, but I dont see anything change when right clicking on the data portal, is there a further step I need to do to make this work as intended? Thank you for you help!
03-09-2022 08:41 AM
Oh, sorry I have forgotten to mention that you need to save the code as file and register the file as user command.
Greetings
Walter
03-09-2022 10:21 AM
Yes it worked when I did that thank you very much! Is there any way to get the list of channels that are currently highlighted in the data portal?
03-10-2022 01:22 AM
Here is an example:
Call AddUserCommandToEvent("Portal.Events.OnShowingContextMenu","MyPortalOnShowingContextMenu")
Call AddUserCommandToEvent("Portal.Events.OnContextMenuPointSelected","MyPortalOnContextMenuPointSelected")
'-------------------------------------------------------------------------------
Sub MyPortalOnShowingContextMenu(ParentObj, MenuPoints)
If (ParentObj.IsKindOf(ePortalList)) Then
Call MenuPoints.Add("My Portal List Menu", 1)
End If
If (ParentObj.IsKindOf(ePortalStructure)) Then
Call MenuPoints.Add("Add <_Test> to channel name Menu", 2)
End If
End Sub
'-------------------------------------------------------------------------------
Sub MyPortalOnContextMenuPointSelected(ParentObj, MenuPoint)
Select Case MenuPoint.ID
Case 1 Call MsgBoxDisp("DIAdem-Portal: My List Menu selected")
Case 2 Call DoSomeThing
End Select
End Sub
'-------------------------------------------------------------------------------
sub DoSomeThing
dim oChn
if Portal.Structure.Selection.Item(1).IsKindOf(eDataChannel) then
set oChn = Data.GetChannel(Portal.Structure.Selection.Item(1).GetReference(eReferenceDefault))
oChn.Name = oChn.Name & "_Test"
end if
end sub
Greetings
Walter
03-10-2022 07:47 AM
Thank you so much for the help! I appreciate it!