Android Question Start a sub in B4XPages

AlpVir

Well-Known Member
Licensed User
Longtime User
I'm editing the Camera2 project https://www.b4x.com/android/forum/threads/camera2-still-images-and-videos.83920/ which is made up of 3 "elements" :
- Main
- B4XMainPage
- CamEx2.
I would need to launch the CaptureVideo sub (which is in B4XMainPage) from Main.
Precisely here :
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
  If KeyCode=24 Then
     Log ("CAPTURE VIDEO")
  '    ?????????????????????
  End If
  'Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub
I don't know B4XPages well yet so I can't get what I want.
Any help will be appreciated
 

AlpVir

Well-Known Member
Licensed User
Longtime User
Thanks but that doesn't sound like what I asked for.
I just want to run the CaptureVideo sub
Something like that
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode=24 Then
        Log ("CAPTURE VIDEO")
        CallSubDelayed(B4XMainPage,"CaptureVideo")
    End If
End Sub
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi @AlpVir , did you try @klaus suggestion?
You should modify the Activity_KeyPress sub in Main as showed by Erel in his solution.
Then add sub B4XPage_KeyPress in your B4xMainPage, test keycode for the value you need (24) and run the sub you indicated (CaptureVideos)

This scheme has the benefit of giving any B4xPage the ability to run that sub (provided that page has a proper B4XPage_KeyPress sub)

Note by Erel:
And implement B4XPage_KeyPress in the relevant pages.
The back key will be handled in the CloseRequest event sub.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…