Character counting ?

There’s a way to do a characters counting? to limit the newTextBox.

Thanks [import]uid: 23063 topic_id: 18259 reply_id: 318259[/import]

Found it

print( string.len( textBoxField.text ) ) -- number of characters  

but my question now is how to block new characters from keyboard?

anyone knows [import]uid: 23063 topic_id: 18259 reply_id: 69914[/import]

What do you mean with block new characters? [import]uid: 14018 topic_id: 18259 reply_id: 70000[/import]

The user can’t put more words

If limit was 800 words, he can’t put 801 or more [import]uid: 23063 topic_id: 18259 reply_id: 70027[/import]

Place an if statement that checks how many characters the user has typed inside an enterFrame function - if limit is reached shrink word down to 800 that should do the trick [import]uid: 14018 topic_id: 18259 reply_id: 70125[/import]

but how I will block this?

if strin.len ( textBoxField.text ) == 800 then  
 local hit800Text = display.newText( "", 0, 0, nil, 15 )  
 hit800Text.text = textBoxField.text  
  
elseif string.len( textBoxField.text ) \> 800 then  
 textBoxField.text = hit800Text  
  
end  

something like that? [import]uid: 23063 topic_id: 18259 reply_id: 70151[/import]

yeah something like that, except don’t declare hit800Text local inside the if-statement, that will give you an error

local function checkText()  
 if string.len(textBoxField.text) \>= 800 then  
 textBoxField.text = string.sub(textBoxField.text, 0, 800)   
 end  
Runtime:addEventListener("enterFrame", checkText)  

Try this, it creates an enterFrame-function that checks the size of textBoxField.text every frame, if it exceeds 800 characters then it subtracts everything after 800 [import]uid: 14018 topic_id: 18259 reply_id: 70165[/import]