Forum Archive

How to set focus to textfield (2)

PetervdKamp

How to set focus to a textfield was subject of an earlier forum discussion. The solution that was given is to call textfield.begin_editing() (as present in the delegate). This method is not implemented in the current version of Pythonista. Instead there are textfield_did_begin_editing and textfield_should_begin_editing. I used both methods to give focus to a textfield, without result. So, is it still possible to give focus to a textfield? If yes, what do I wrong?

dgelessus

Interesting. I thought I was only imagining things when I thought that there was a begin_editing method before, but it seems that that method was removed at some point.

JonB

What are you considering the 'latest version'? 1.6 beta, or 1.5?

Although begin_editing is missing from the docs, in 1.5 it is present for both TextView and TextField. Note that this method is called on the TextField object, not on the delegate!


t=ui.TextField() 
t.begin_editing()
t.present()

PetervdKamp

Thanks JonB, your solution did the trick. It didn't come to my mind to call it on the TextField object, because I was convinced that it should be called from the delegate. Kind of tunnel vision…..
Thanks again.