I have discovered a problem (maybe I should have known it) in using the hard 'backspace' key to switch between panels.
A simple app has two full-screen panels... 'pnlMain' and 'pnlResults', the latter is hidden and made visible to show the results of a calculation.... and then hidden again by:-
Unfortunately the backspace key on the soft keyboard returns the same KeyCodes.KEYCODE_BACK as the hard key. Which means every time the user hits the soft backspace whist editing an EditText on the main panel the interstitial ad is shown and the program exits.
I think I am missing something simple here. How do I differently handle the user keystroke whilst editing text with focus on the main panel, while retaining the hard-key functionality for program exit???
A simple app has two full-screen panels... 'pnlMain' and 'pnlResults', the latter is hidden and made visible to show the results of a calculation.... and then hidden again by:-
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
If pnlResults.Visible = True Then
pnlResults.Visible = False
Return True
End If
End If
'We got here because only the main panel was
'visible and the user hit backspace
'There then follows some more code here to show an interstitial
'ad on user requested exit
End Sub
Unfortunately the backspace key on the soft keyboard returns the same KeyCodes.KEYCODE_BACK as the hard key. Which means every time the user hits the soft backspace whist editing an EditText on the main panel the interstitial ad is shown and the program exits.
I think I am missing something simple here. How do I differently handle the user keystroke whilst editing text with focus on the main panel, while retaining the hard-key functionality for program exit???