4

I have a TextField and want to listen to the event when the user finished typing and wants to go on. I neither want to call a function each time a user presses any key nor I want to add a submit button. The keyboard offers a 'done' button, so why don't use this. The only question which follows is how to listen to that specific event.

shaedrich
  • 5,457
  • 3
  • 26
  • 42

2 Answers2

2

returnPress should do what you want:

<TextField (returnPress)="returnPress()" 
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
2

With NativeScript 3 you can use the new blur event. That way you will not only call a function when the Enter key is pressed, but also when the user leaves the field by other means (tap a different field for instance).

See the API reference here https://docs.nativescript.org/api-reference/classes/_ui_text_base_.textfield.html#blurevent

Example:

<TextField (blur)="userLeftTheField()"> 
Eddy Verbruggen
  • 3,550
  • 1
  • 15
  • 27