Android Question AddMenuItem in B4XPages

bocker77

Active Member
Licensed User
Longtime User
I am converting an old B4A program to B4XPages. It uses adding menu items. I get it all to work but when the back button is hit while pnlChangeRange panel is viewed the app goes away after the return at the end of the B4XPage_CloseRequest sub. The IDE stays active to the app meaning the Stop icon is still enabled. This is in both Debug and Release mode. The log is not giving me any error in both filtered and unfiltered. Not sure where the return goes. I am assuming that I need to do something somewhere in my code with the return. I did not have any success in scouring this forum for any solution.

B4X:
    B4XPages.AddMenuItem(Me, "Change Detection Range")
...
Sub B4XPage_MenuClick (Tag As String)
...
    Select Tag
        Case "Change Detection Range"
            ChangeFindRange
...
End Sub

Sub ChangeFindRange
    pnlProtect.BringToFront
    pnlChangeRange.BringToFront
    
    bChange = True
End Sub

Private Sub B4XPage_CloseRequest As ResumableSub
...
    If bChange Then
        pnlChangeRange.SendToBack
        If Not(bWeb) Then pnlProtect.SendToBack
        bChange = False
    End If
...
    Return True       <== issue is after this line
End Sub
 

bocker77

Active Member
Licensed User
Longtime User
After further testing it happens whenever the Back button is pressed in the app. It has nothing to do with the menus. I am using the two subs, one in Main and the other in B4xPages, as is.

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Private Sub B4XPage_CloseRequest As ResumableSub
    Return True
End Sub

Obviously I need to do more searching and reading about B4X when it comes to the Back button.
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
Actually I thought about that before I read your reply. But then again in my testing I thought I tried that. Apparently I didn't. That fixed my issue.

Just to clarify why I got confused, my B4A code had Return True if the backbutton was pressed. That worked in B4A.

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        ...
        Return True
    End If
    Return False
End Sub

Thank Walt for your reply!!!!!
 
Upvote 0
Top