Editing Text Field Input

Hey everybody,

I’m building a business app where I need to ask for the user’s phone #.  I’m using a native text field, and I’m trying to edit the input contents as the user is typing (I’ve got some logic i’m trying to execute during the “editing” phase).  My goal is insert the “-” and “( )” for area codes.

I’ve run into some trouble, because it appears to me that the textField’s text can only be set directly to a string, and not to a string variable.  In the event handler, while example 1 works:

[lua]

local onTextInput = function( event )

    if ( event.phase == “began” ) then

    elseif (event.phase == “editing”) then

        event.target.text = “BOOM SHAKA LAKA”

    elseif (event.phase == “submitted”) or (event.phase == “ended”) then

    end

end

[/lua] 

Example 2 doesn’t work:

[lua]

local newText = “BOOM SHAKA LAKA”

local onTextInput = function( event )

    if ( event.phase == “began” ) then

    elseif (event.phase == “editing”) then

        event.target.text = newText

    elseif (event.phase == “submitted”) or (event.phase == “ended”) then

    end

end 

[/lua]

I need example 2 to work so I can run the logic to correctly display “( )” and “-” depending on what the user is typing and deleting.  Anyone have a guess why this isn’t working?

Thanks!

Dan

After much more testing, I think I figured this out - will post shortly.

After much more testing, I think I figured this out - will post shortly.