B4J Question BringToFront redux [solved]


Active Member
Licensed User
I have a Pane containing a TableView and a ListView that pops up when I right click the mouse on the TableView.
Below that Pane, I have a TextArea.

When I right click on the last line of the TableView, the popup mouse ListView is hidden behind the TextArea:

Here is what it looks like when I click on the last 3 lines:



I tried using this tip:
for the Pane, the TableView and the mouse ListView but nothing works. The project is quite big so I can't really attach it but if this is not enough information, I will try to create a small one to show the problem.

This is the pop-up menu code:

' SecondaryButtonPressed is the right mouse button
Sub tvMenuSettings_MouseClicked( EventData As MouseEvent )
    Dim x, y As Int
    ' this event is called *after* SelectedRowChanged()
    If CurrentNVP.Length > 2 And EventData.SecondaryButtonPressed = True Then
        If GetMenuCellValue( CurrentNVP( 0 ), 3 ).Length > 0 Then
            'Log( "SecondaryButtonPressed" )
            x = EventData.X
            y = EventData.y
            lvMouseMenu.Items.Add( "===> Cancel" )
            lvMouseMenu.Items.Add( "Load Default")
            lvMouseMenu.SetSize( lvMouseMenu.Width, lvMouseMenu.Items.Size * 30dip )
            lvMouseMenu.Top = y + 50dip
            lvMouseMenu.Left = x
            lvMouseMenu.Visible = True
            BringToFront( pnMenuSettings ) ' the Pane
            BringToFront( tvMenuSettings ) ' the TableView
            BringToFront( lvMouseMenu ) ' the ListView
            DisplayTimer.Enabled = True
        End If
    End If
End Sub ' tvMenuSettings_MouseClicked()


Active Member
Licensed User
Now that I think of it, it looks like I need to relocate the popup higher so that it is entirely contained in the pane.


Active Member
Licensed User
I fixed it like this:
lvMouseMenu.Top = y + 50dip
If lvMouseMenu.Top + lvMouseMenu.Items.Size * 30dip >= pnMenuSettings.Height Then
       lvMouseMenu.Top = pnMenuSettings.Height - lvMouseMenu.Items.Size * 30dip
End If