### Open a ContextMenu

An example of assigning a ContextMenu to a Button and open.
Example 1
'Sub to bringup a contextmenu
'Private btnExport As Button
'Private cmExport As ContextMenu
'Private mnuExportCSV1 As MenuItem
'Private mnuExportCSV2 As MenuItem
'Reference: https://docs.oracle.com/javafx/2/api/javafx/scene/control/ContextMenu.html
`Sub btnExport_Action
'Show the contextmenu assigned to the button - to avoid right click the contextmenu is shown when clicking on the button.
'Create the JavaObject which will become a contextmenu
Dim joContextMenu As JavaObject = cmExport
'Call the API method show with parameter right, showing the contextmenu right from the position given (5 and 10).
'Note the positions must be given as double
joContextMenu.RunMethod("show", Array(btnExport, "RIGHT", 5.0, 10.0))
End Sub`
`Sub mnuExportCSV1_Action
Log("mnuExportCSV1_Action")
End Sub`
`Sub mnuExportCSV2_Action
Log("mnuExportCSV2_Action")
End Sub`
Example 2
'The tools button has a contextmenu assigned. When clicking the button the contextmenu is shown as a popup
`Sub btnTools_Action
'Show the contextmenu assigned to the button - to avoid right click the contextmenu is shown when clicking on the button.
'Create the JavaObject which will become a contextmenu
Dim joContextMenu As JavaObject = cmnuTools
'Call the API method show with parameter left (other options are right, top, bottom) which shows the contextmenu right from the position given (5 and 10).
'Note the positions must be given as double
joContextMenu.RunMethod("show", Array(btnTools, "LEFT", 5.0, 10.0))
End Sub`

Changed: , Category: Buttons, File: T6C167M1232.htm, ID: 1232