Android Question Large Keypad as a Class - Problem

doncx

Active Member
Licensed User
Longtime User
I have created a large keypad as a class, easily callable from activities with parameters to control number range, number of digits, etc.

This large keypad works well in bright sunlight on the deck of an active fishing vessel.

The typical implementation is to tap on a view which brings up the keypad. When "Done" is tapped, the keypad is cleared and a specified label now contains the value entered in the keypad.

This works quite well. However, when furiously tapped in exactly the right (wrong) way, the keypad appears to freeze. In fact, the app thinks the keypad has been cleared from the screen but it hasn't. This is easily rectified by rotating the tablet, causing the keypad to disappear, exposing the fully functional app screen below.

You really have to tap like a madman (wildly, all over the screen) to make it happen, but apparently fishermen are madmen, because I get reports from the field (ocean) that it occurs.

To make the problem happen, I drum my fingers on the tablet, both on the main screen and the keypad layout. Eventually I notice that the keypad appears locked. Rotate, and all is well.

I can't figure it out. Anyone with a few minutes who enjoys a challenge is invited to help!

Please find test code attached. Requires JavaObject, Phone, Reflection, and StringFunction libraries.

Thanks for any ideas.
 

Attachments

  • KeypadTest.zip
    60.7 KB · Views: 128

klaus

Expert
Licensed User
Longtime User
You should add a dummy event for the bg panel to consume the panel events.

B4X:
Private Sub blob_Click
    ' dummy event
End Sub
Depending on where you click onto the keyboard out of the views insides the keybord the event can be transmitted to underlying views.

Another question, why don't you use it as a CustomView?

You could simplify the ButtonX_Click events using a same routine and the Sender object.

The keyboard doesn't look good on my device, Samsung S6.

upload_2017-7-14_20-16-13.png
 
Last edited:
Upvote 0

doncx

Active Member
Licensed User
Longtime User
Thanks for your suggestion, Klaus. It makes good sense, however with some effort I'm still able to trigger the problem.

I've not created any Custom Views and will look into that. Do you think it could solve the problem?

As for the appearance on your S6, the app was created for tablets and I haven't tested on phones.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
I agree with Klaus. I tested the app without the blob_Click sub & found that if you tapped in the right place you were actually tapping the "Tap for Keypad" button & therefore creating another instance of the keypad. This effectively leaves your first instance an orphan (but still active), so when you tap on the "Done" button on the second instance, it is closed leaving your first instance on the screen.

When I put a blob_Click sub in the NumericKeypad class, I couldn't reproduce the issue.

- Colin.
 
Last edited:
Upvote 0

doncx

Active Member
Licensed User
Longtime User
The b4a community has rescued me again. I originally misread Klaus' post and created a dummy click for 'bg' (the panel) and not 'blob' (it's initialized name).

Many Thanks to you both for the fix and advice.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Well, setting an EventName different from the views name leads to this mistake.
I set a different EventName only when I want the same event routine for several views.

In your case:
Replace the EventNmae for the Buttons from Button0, Button1 etc to Buttons and then one routine:
B4X:
Sub Buttons_Click
    Private btn As Button

    btn = Sender
    AddDigitIfPossible(btn.Text)
End Sub
Not for ButtonCe and ButtonOK
 
Upvote 0

doncx

Active Member
Licensed User
Longtime User
Klaus -

If I'm reading your message correctly, you are suggesting that I should initialize the panel "bg" as "bg" and not "blob".

If so, then I've got it. Thanks for the education.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
If I'm reading your message correctly, you are suggesting that I should initialize the panel "bg" as "bg" and not "blob".
Yes.

But, I would have given it the name pnlKeyboard, pnl for Panel and Keyboard for the purpose.
And then pnlKeyboard.Initialize("pnlKeyboard")
 
Upvote 0
Top