I made a number keypad that works like a Pythonista calculator. Only difference is the I have two text fields. I added a "Next Field" button so you can switch to the next text field. How can when I switch text fields use the same number pad? I looked all through the wiki and don't see anything. There a way you check what text field is active for text input?
def num_input(sender):
'@type sender: ui.Button'
t = sender.title
sze_tf = sender.superview['size_tf'] # 1st text field
spd_tf = sender.superview['speed_tf'] # second text field
if t in '0123456789':
if spd_tf.text == 'avg. speed':
spd_tf.text = t
else:
spd_tf.text += t
elif t == '.' and spd_tf.text[-1] != '.':
spd_tf.text += t
elif t == 'DEL':
spd_tf.text = spd_tf.text[:-1]
else:
spd_tf.text += t
