Hey Corona,
Seeing as to how responsive and polite the Corona community is, I would like to ask a question regarding the userInputs in textboxes. I am working on the free Windows build of Corona and am making an app for android.
The functionality of this app depends on the app reading when the user is typing and not typing.
I understand the began, editing, and ended phases of corona. The problem is I cannot figure out how to allow corona to read when the user is typing something into the textbox and when the typing stops (when the user is “actually” editing/when the user is “actually” not “editing” and editing has not ended). The ended phase should not be called until the timer stops or if the user clicks out of the textbox.
To simplify the above,
The user is “currently typing”= clock start, clock text turns blue.
The user has stopped typing=clock text turns green for two seconds
The user has not typed in the two seconds= clock text turns red for five seconds.
The user does not type in all two seconds and five seconds= current text in the textbox is deleted, clock text stays red until the user types again.
Extra note: If the user start typing once again in any of the time periods(two or five seconds), the cycle(green then red then delete) is reset(blue), until he stops typing once again, meaning nothing will be deleted after the total seconds(seven)
I am relatively new to corona(beginner level of self-taught, (I’m 16 years old)), and greatly appreciate all the help I can get. Thanks everybody. If there is any other information that I can provide that you need, please let me know.
local function textListener( event ) if ( event.phase == "editing" ) then clockText:setFillColor( 0.7, 0.7, 1 ) timer.resume(countDownTimer) print( event.newCharacters ) end end local function textListener2( event ) if (not event.phase== "editing") then clockText:setFillColor(1,0,0) end end local function textListener3( event ) if ( event.phase == "ended" ) then clockText:setFillColor( 1, 0, 0 ) print( event.newCharacters ) end end local function updateTime() -- decrement the number of seconds secondsLeft = secondsLeft - 1 -- time is tracked in seconds. We need to convert it to minutes and seconds local minutes = math.floor( secondsLeft / 60 ) local seconds = secondsLeft % 60 if(minutes== 0 and seconds== 0) then native.setKeyboardFocus(nil) textbox.isEditable=false end -- make it a string using string format. local timeDisplay = string.format( "%01d:%02d", minutes, seconds ) clockText.text = timeDisplay end local function clickOutside() native.setKeyboardFocus(nil) end local function changescenes () composer.gotoScene("MainMenu", {effect= "fade", time= 300}) native.setKeyboardFocus(nil) end
Here the little beginner/simple code I got.
Update*- I found this code in corona about live search terms, not really sure how it is relevant. But that is what I’m asking, how I can ask corona to detect “live” typing. Thanks everybody, please let me know if you need anything.
Update**- This app is due for me by Nov.2 all help will be greatly appreciated, and ill give you a shout out at the presentation, where I have to present the app. Thanks guys.