Disable Return Key from native.newTextBox?

I am allowing users to add a good amount of text into a native.newTextBox field, but I want to restrict them from using the return key (which causes a new line \n)…

Anyone know how to Disable Return Key from native.newTextBox or a work around?

I think you can setReturnKey to none only on Android. See 

https://docs.coronalabs.com/api/type/TextField/setReturnKey.html

Sadly that didn’t work :frowning: it just defaulted… Ksan would you think an approach via the input listener would manage it? It just sucks that the textBox does not support the even phase “submitted”…

Yup. I think thats your only choice. Wait for them to enter the text and then use string functions to get rid of the \n.

Yup thanks ksan, for anyone looking for a solution use this snippet:

local sSub=string.sub -- inside field input listener if (e.phase=="editing") then if (e.newCharacters=="\n") then field.text=sSub(field.text,1,#field.text-1) end end

Super! Thanks for sharing your solution.

I think you can setReturnKey to none only on Android. See 

https://docs.coronalabs.com/api/type/TextField/setReturnKey.html

Sadly that didn’t work :frowning: it just defaulted… Ksan would you think an approach via the input listener would manage it? It just sucks that the textBox does not support the even phase “submitted”…

Yup. I think thats your only choice. Wait for them to enter the text and then use string functions to get rid of the \n.

Yup thanks ksan, for anyone looking for a solution use this snippet:

local sSub=string.sub -- inside field input listener if (e.phase=="editing") then if (e.newCharacters=="\n") then field.text=sSub(field.text,1,#field.text-1) end end

Super! Thanks for sharing your solution.