Numeric keypad for text field

Im trying to using the numeric keypad to insert numbers into a text field as string data.
in the help file I found:

event.source.text = str(system.gui.showNumericKeypad(int(event.source.text)))

but then I get the error:

[code]Traceback (most recent call last):

File “event:mouseClicked”, line 1, in

ValueError: invalid literal for int() with base 10:

Ignition v7.6.3 (b2013090513)
Java: Sun Microsystems Inc. 1.6.0_31
[/code]

any ideas what im doing wrong?

thank you.

You get this error if the value from the source is blank/None/empty string/etc. Set your default Text value for your Text Field to 0 or do the error checking inside your code:

event.source.text = str(system.gui.showNumericKeypad(int(event.source.text if isinstance(event.source.text, int) else 0)))

thank you.