Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Performance issues - composer.gotoScene and text listener
Started by bbk Jan 11 2018 07:59 AM

- - - - -
No replies to this topic
gotoscene textlistener string.find
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Enthusiast

  • 61 posts
  • Corona SDK

Sorry, I have two questions in one.


We are developing a business App and I am experiencing performance issues.


One is when I change scene and at times I experience that the previous scene remains on the screen (I can see half of it) and the next scene hangs. I am aware that this possibly could be fixed by looking at all that happens during the scene change, but is it a problem that others also experience or am I the only one ?


The other is a function to test and remove illegal characters in a textfield. In the text listener I have added the following code: 

function textListener( event )

  if ( event.phase == "began" ) then
    -- (...)
  elseif ( event.phase == "ended" or event.phase == "submitted" ) then
    -- (...)
  elseif ( event.phase == "editing" ) then
      --print( "new char: "..event.newCharacters )
      local newChar = event.newCharacters
      if newChar then
        local thePos =  string.find(theAllowedCharacters,newChar) or 0

        if thePos == 0 then

       --  print("Illegal char - replace with previous text")

          event.target.text = thePreviousText

        --  print("Legal char")
          thePreviousText = event.target.text



This seems to work OK, but if I keep on hitting the keyboard keys quickly I end up with an error on the string.find function that says "unfinished capture" and the program crashes.


Is there a solution to allow Corona to execute the code before it continues the processing - or do you have a better way to test of acceptable input (in this case I do not want characters outside the normal letters and numbers (including national characters like æ ø å ä ö ü and î etc.....)