vanngoh
vanngoh

Reputation: 658

Nativescript - How to disable the return key to add newline in editable TextView

Official Documentation of Nativescript TextView

According to the link above, there's an attribute called returnKeyType. But it's not working...

Is there any other proper way to set the returnKeyType? Or simply disable the newline when pressing the return key?

Thank you!

Upvotes: 1

Views: 766

Answers (3)

Wilson Lau
Wilson Lau

Reputation: 253

Try this, this is a suitable approach for your case

let tv = <TextView>page.getViewById("tv");

tv.on("blur", () => {
   tv.text = tv.text.replace(/\n/gm, " ");
})

Upvotes: 3

Sow
Sow

Reputation: 46

I don't get it, if you only need one line, why don't you use TextField instead of TextView? TextField does exactly what you are asking for.

Upvotes: 0

Manoj
Manoj

Reputation: 21888

There is a open feature request, but there is also a workaround that should work for now, just use 1 instead of 3 in example.

Upvotes: 0

Related Questions