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.
Getting What Key is Pressed on Keyboard
-
Hey guys I have a simple question. I saw a post on the forum here that was related to this but unfortunately, the only answer on that post did not clarify enough for me. So what I need to ask is this:
Say I ask for a user’s input in a text field, how do I make it so that instead of having to press a button in order for the user’s input to be processed, the user can simply hit “return” on the keyboard.
-
For TextField, which contains a single line, pressing Enter automatically calls the
action
method, so the following also worksdef a(sender): #called when done entering text print(sender.text ') t=ui.TextField(a) t.action=a t.present('popover')
For TextView, you would instead use one of the delegate methods textview_did_change, or textview_should_change.
-
@procryon , if you look at one of my code examples in this thread you see the delegate being used as @JonB pointed out.
You can see the TextFields Delegate Documentation here