Reputation: 489
Apparently I can't find a focus event handler in NativeScript's documentation or API reference of TextFields elements. Am I wrong?
Or, is there a way to introduce the onFocus event extending the existing Nativescript's element?
(I am using typescript without Angular 2)
Upvotes: 0
Views: 1750
Reputation: 3550
A PR for adding focus
is pending review. Won't be long before you can use it on TextField
and TextView
elements!
Upvotes: 1
Reputation: 2094
You can use the on
method that is mentioned here. I don't know if this is what you are looking for but here is an example:
In XML:
<TextView id="textfield" textWrap="true" tap="textfieldTap"/>
In js file:
var myTextfield = page.getViewById("textfield");
myTextfield.on("tap", function() {
console.log("Hello from the other side");
});
Also, there is another way to listen to focus event on TextField. As we have the tap="textfieldTap"
inside the XML TextField tag, then we can declare a function in the js to listen to that event:
function textfieldTap(args) {
console.log("Textfield tap " + args.text);
}
exports.textfieldTap = textfieldTap;
Upvotes: 1