Having trouble getting the Activity_KeyPress(KeyCode) to the current page.
My scores routine has a special looking dialog that kind of looks numeric key pad showing that I need to handle / pass the 0 -> 9 keys
Normally the user just taps the keypad and that works fine. But I am trying to handle users that want to have a wireless keypad.
My goal would to know if they have a wireless keypad/keyboard and handle the keys or taps on the screen.
In my main I have
But the ActivityKeyPress in the scores / showing page doesn't get called
I can force Main to send the keycode to the right page but getting the proper page and calling it
This code works. But is not the right way to pass the key strokes - because the scores page is not always showing.
I thought B4XPages.Delegate.Activity_KeyPress(KeyCode) would pass the keycode on to the active / showing page
How do I pass the keycode correctly - is delegrate.activity_keypress not the right way
Thanks for any help
My scores routine has a special looking dialog that kind of looks numeric key pad showing that I need to handle / pass the 0 -> 9 keys
Normally the user just taps the keypad and that works fine. But I am trying to handle users that want to have a wireless keypad.
My goal would to know if they have a wireless keypad/keyboard and handle the keys or taps on the screen.
In my main I have
B4X:
Sub Activity_KeyPress(KeyCode As Int) As Boolean
If mPagesManager.IsInitialized Then
#if Debug
LogColor($"Main::Activity_KeyPress - Key:${KeyCode}"$, Colors.Green)
#end if
Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End If
Return False
End Sub
But the ActivityKeyPress in the scores / showing page doesn't get called
B4X:
' Code from Page Scores which is showing when doing this test
Public Sub Activity_KeyPress(KeyCode As Int) As Boolean
LogColor($"${DEFINE_PageName}::Activity_KeyPress - Key:${KeyCode}"$, Colors.Green)
If mNumericKeyPad.IsInitialized And mNumericKeyPad.IsShowing Then
Return mNumericKeyPad.KeyPress(KeyCode)
End If
Return false
End Sub
I can force Main to send the keycode to the right page but getting the proper page and calling it
This code works. But is not the right way to pass the key strokes - because the scores page is not always showing.
I thought B4XPages.Delegate.Activity_KeyPress(KeyCode) would pass the keycode on to the active / showing page
B4X:
Change main code to
Sub Activity_KeyPress(KeyCode As Int) As Boolean
If mPagesManager.IsInitialized Then
#if Debug
LogColor($"Main::Activity_KeyPress - Key:${KeyCode}"$, Colors.Green)
#end if
Dim Scores As pFWScores = B4XPages.GetPage(cBBsGlobals.DEFINE_PageName_FWScores)
Return Scores.Activity_KeyPress(KeyCode)
End If
Return False
End Sub
How do I pass the keycode correctly - is delegrate.activity_keypress not the right way
Thanks for any help