Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
TextField loses focus
-
I want to stop editing a TextField whenever I click somewhere other than the TextField. I realize hitting return stops editing and clicking on another TextField stops the editing of the previous field. But if I click on a button, for example, the TextField is was in when I clicked the button is still in edit mode. How do I stop editing a text field when it loses focus?
-
@BGKirkham, see this very recent thread.
-
Thank you for your response. I did see that thread, but it doesn’t fully answer the question. I just used a button as an example. I’m more interested in determining when a user clicks on something, anything, that isn’t the textfield that is currently being edited. Sorry if I didn’t make that more clear in the OP.
ETA: That “anything” could be a label or even the window itself.
-
@BGKirkham, to my knowledge, there is no generic, built-in way to detect ”losing focus”. I would suggest placing a background ui.View to detect taps on it and call
end_editing
on your TextFields — Labels etc. should be transparent to touches.This could be made a bit generic by running through all subviews, and calling
end_editing
on all views that have the method. -
Thank you. I guess I need to dial back my goals
-
You can call
textfield.end_editing()
. See http://omz-software.com/pythonista/docs/ios/ui.html#textview