Collection: MenuPoints

DIAdem 2018 Help


Edition Date: June 2018
Part Number: 370858P-01
View Product Info

DOWNLOAD (Windows Only)


DIAdem 2017 Help
DIAdem 2018 Help
DIAdem 2019 Help
DIAdem 2020 Help
DIAdem 2020 SP1 Help

Collection of context menu items.

In a script you can access the context menus of the File Browser, Data Browser, Search Results List of a DataFinder, Search Result List of a Data Store, a Tree in user dialog boxes, an Extended Table in user dialog boxes and the channel preview, as well as the context menus of DIAdem VIEW.

Read and write access.

Note  To test the following example script, you must first save the script and register the script as a user command in the dialog box that opens when you select Settings»Extensions»User Commands.

The following example executes the MyNavigatorOnShowingContextMenu user command when you open the context menu in DIAdem NAVIGATOR and the MyViewOnShowingContextMenu user command when you open the context menu in DIAdem VIEW. These user commands add a new entry to the existing context menus when you open the context menu in the browser, the search results list, the axis system, or the channel table.
When you click one of the defined context menu items, the example executes the MyNavigatorOnContextMenuPointSelected user command or the MyViewOnContextMenuPointSelected user command and displays the selected item in a message. 

' --- For DIAdem-NAVIGATOR ------------------------------------------
Call AddUserCommandToEvent("Navigator.Events.OnShowingContextMenu","MyNavigatorOnShowingContextMenu")
Call AddUserCommandToEvent("Navigator.Events.OnContextMenuPointSelected","MyNavigatorOnContextMenuPointSelected")

Sub MyNavigatorOnShowingContextMenu(ParentObj, MenuPoints)
  If (ParentObj.IsKindOf("Browser")) Then
    Call MenuPoints.Add("My Browser Menu Point", 1)
  End If
  If (ParentObj.IsKindOf("ResultsList")) Then
    Call MenuPoints.Add("My ResultsList Menu Point", 2)
  End If
End Sub

Sub MyNavigatorOnContextMenuPointSelected(ParentObj, MenuPoint)
  Select Case MenuPoint.ID
    Case 1    Call MsgBoxDisp("DIAdem-NAVIGATOR: MyMenuPoint1 selected")
    Case 2    Call MsgBoxDisp("DIAdem-NAVIGATOR: MyMenuPoint2 selected")
  End Select
End Sub


' --- For DIAdem-VIEW -----------------------------------------------
Call AddUserCommandToEvent("View.Events.OnShowingContextMenu","MyViewOnShowingContextMenu")
Call AddUserCommandToEvent("View.Events.OnContextMenuPointSelected","MyViewOnContextMenuPointSelected")

Sub MyViewOnShowingContextMenu(Area, MenuPoints)
  If (Area.DisplayObjType = "CurveChart2D") Then
    Call MenuPoints.Add("My CurveChart Menu Point", 1)
  End If
  If (Area.DisplayObjType = "ChannelTable") Then
    Call MenuPoints.Add("My ChannelTable Menu Point", 2)
  End If
End Sub

Sub MyViewOnContextMenuPointSelected(Area, MenuPoint)
  Select Case MenuPoint.ID
    Case 1    Call MsgBoxDisp("DIAdem-VIEW: MyMenuPoint1 selected")
    Case 2    Call MsgBoxDisp("DIAdem-VIEW: MyMenuPoint2 selected")
  End Select
End Sub

The following example shows the functionality of a context menu in an extended table. If you right-click a cell, the example creates a context menu and displays the selected entry of the context menu.

Sub XTable1_EventContextMenuPointSelected(ByRef This, Row, Col, MenuPoint)
    Call MsgBox("Row: " & Row & "; Column: " & Col & VBCrLf & "Menu entry: " & MenuPoint.Text)
End Sub

Sub XTable1_EventContextMenuShowing(ByRef This, Row, Col, MenuPoints) 
  Call MenuPoints.Add("Menu 1",1)
  Call MenuPoints.Add("Menu 2",2)
End Sub

The following example creates a tree in a user dialog box. If you right-click a node, the example creates a context menu and displays the selected entry of the context menu.

Sub Tree1_EventInitialize(ByRef This)
  Call CreateDefaultTree(This)
End Sub

Sub Tree1_EventContextMenuShowing(ByRef This, ByRef Node, MenuPoints)
  Call MenuPoints.Add("Menu 1",1)
  Call MenuPoints.Add("Menu 2",2)
End Sub

Sub Tree1_EventContextMenuPointSelected(ByRef This, ByRef Node, MenuPoint)
    Call MsgBox("Selected Node: " & Node.Text & VBCrLf & "Menu entry: " & MenuPoint.Text)
End Sub

Sub CreateDefaultTree(ByRef This)
  Dim oRoot, oMainNode
  Set oRoot = This.Nodes.Add("Tools")
  oRoot.Key = "tools"
  oRoot.Expanded = true
  Set oMainNode = oRoot.Nodes.Add("Electric Tools")
  oMainNode.Key = "electric"
  oMainNode.Nodes.Add("Drill").Key = "drill"
  oMainNode.Nodes.Add("Saw").Key = "saw"
  Set oMainNode = oRoot.Nodes.Add("Hand Tools")
  oMainNode.Key = "handtool"
  oMainNode.Nodes.Add("Hammer").Key = "hammer"
  oMainNode.Nodes.Add("Screwdriver").Key = "screwdriver"
  oMainNode.Nodes.Add("Tongs").Key = "tongs"
End Sub

Properties

Count

Methods

Add | IsIDUsed | Item | Remove | RemoveAll

WAS THIS ARTICLE HELPFUL?

Not Helpful