DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Editing the right click context menu

Solved!
Go to solution

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?

0 Kudos
Message 1 of 7
(2,139 Views)

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

0 Kudos
Message 2 of 7
(2,045 Views)

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!

0 Kudos
Message 3 of 7
(2,033 Views)

Oh, sorry I have forgotten to mention that you need to save the code as file and register the file as user command.

Walter_Rick_0-1646836879385.png

 

Greetings

Walter

 

0 Kudos
Message 4 of 7
(2,027 Views)

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? 

0 Kudos
Message 5 of 7
(2,021 Views)
Solution
Accepted by topic author BrandonHosken

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

Message 6 of 7
(2,005 Views)

Thank you so much for the help! I appreciate it!

0 Kudos
Message 7 of 7
(1,997 Views)