B4J Question Is there any way to include a ContextMenu on a B4XTable?

Mikelgiles

Active Member
Licensed User
Longtime User
I need a way to create a popup menu on a B4XTable by doing right mouse click instead of a left click(which activates B4XTableM_CellClicked that is being used to edit cells). In some other languages I can fake it out by knowing if the left or right mouse caused the event but I have not found how to do that in B4J.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub B4XTable1_CellLongClicked (ColumnId As String, RowId As Long)
   Log("CellLongClicked: " & B4XTable1.GetRow(RowId).Get(ColumnId))
   Dim col As B4XTableColumn = B4XTable1.GetColumn(ColumnId)
   Dim i As Int = B4XTable1.VisibleRowIds.IndexOf(RowId)
   Dim cell As B4XView = col.CellsLayouts.Get(i)
   Dim jo As JavaObject = cm '<--------------------------- global ContextMenu object
   Dim x As Double = robot.RunMethod("getMouseX",Null)' <----- global JavaObject object
   Dim y As Double = robot.RunMethod("getMouseY",Null)
   jo.RunMethod("show", Array(cell, x, y))
End Sub

robot is created with this code in AppStart:
B4X:
robot = robot.InitializeStatic("com.sun.glass.ui.Application").RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
 
Upvote 0
Top