Adding virtual numeric keypad

jschuchert

Active Member
Licensed User
Longtime User
I want to add a numeric keypad to about 15 forms but only want to design one and have it placed on the others at runtime (copying and pasting doesn't work). It would be in a panel with each number a very small button and I would code what happens when a numbered button is pressed. I experimented with addobject and addpanel but apparently don't know what I'm doing. I did it (with expert help) in NSBasic by using code like this in the load event for each form:

SetParent frame2,area_form
frame2.move 156,130 'adjusted the location of the keypad
formname="area"

The actual designed keypad (in frame2) appeared on only on 1 form and the others were added at runtime as a form was called. I'm confident it can be done in b4ppc but need some direction. Thanks.

Jim Schuchert
 

Ariel_Z

Active Member
Licensed User
See the source code I've offered as a solution here: http://www.b4x.com/forum/questions-help-needed/4856-big-ok-button-msgbox.html

The code demonstrates how to add a panel at runtime, how to add a button to it and how to cause it to pop up. It also shows how to consume the relevant events.

You can try it out this and I will be glad to help you out. I guess we can try developing a module that does just this and publish it - many programmers encounter this need.

You will probably have questions - please post them here.
 

taximania

Well-Known Member
Licensed User
Longtime User
Here you go, a simple number pad based on Ariel's code :sign0188:
I'm sure Erel had already done this before ??

The only error check is so that the decimal point can't be pressed twice.

The number entered by pressing the 'X' button is stored in the
global variable 'numer'

And yes, it doesn't need all the _click routines. I was just idle :sign0025:
 

Attachments

  • numericKeyb.sbp
    2.3 KB · Views: 306

jschuchert

Active Member
Licensed User
Longtime User
Thank you. I got that far but am hung up when I need to enter numbers from the keypad into various text boxes. I can't seem to get the 'focus' syntax correct when going from tb to tb. For example:

Sub btn1_click
If tb1.focus = True Then 'this is first text box don't know syntax
tb1.text=tb1.text & "1"
Else
If tb2.focus = True Then 'this is second text box
tb2.text=tb2.text & "1"
End If
End If
End Sub

where is the button 'numerica' added?
how does the 'timer' come in play?
 

jschuchert

Active Member
Licensed User
Longtime User
Adding virtual keypad

Thank you Erel, Ariel and Taximania for the great suggestions. Hopefully I can take it from here with the reservation that I can come back for more excellent advice. You guys are awesome.

Incidentally, for whatever reason, I can not get the 'properties' links (in blue)on the right side of the help screen for the 'controls' to work. They hang up IE and I have to restart. Seems like they worked before.

Jim
 
Top