First time using B4XPage... how can we catch the volume button in B4XPage like we used to be
My Old example :
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
Select Case KeyCode
Case 4 'BACK KEY
RaiseUserEvent("ExecReturn_Keycode_Key","BACK")
Case 24 'VOLUME UP
RaiseUserEvent("ExecReturn_Keycode_Key","VOLUP")
Case 25 'VOLUME DOWN
RaiseUserEvent("ExecReturn_Keycode_Key","VOLDOWN")
End Select
Return True
End Sub
I am able to catch 'back' key using Sub B4XPage_CloseRequest As ResumableSub
Untested code - change Activity_KeyPress in Main module to:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If B4XPages.Delegate.Activity_KeyPress(KeyCode) Then Return True
B4XPages.GetManager.RaiseEvent(B4XPages.GetManager.GetTopPage, "B4XPage_KeyPress", Array(KeyCode))
Return True
End Sub
Handle it with:
B4X:
Private Sub B4XPage_KeyPress (Keycode As Int)
End Sub
You need both. The Sub in Main calls the one in the B4XPage. That is what this line does Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
EDIT: I didn't read your code carefully, You need both Subs exactly as written by Erel above. The one in Main calls the B4XPage_KeyPress Sub in the top page by